[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Bug c++/26757] [4.1/4.2 regression] C++ front-end producing two DECLs with the same UID




------- Comment #16 from mmitchel at gcc dot gnu dot org  2006-04-23 18:14 -------
The correct fix for this issue is for the C++ front-end to save and restore
information about a declaration as scopes are entered and exited.

For example, given:

  extern void f(int);
  void g() {
    extern void f(int = 7);
    f();
  }
  void h() { 
    extern void f(int = 3); 
    f(); 
  }

we should use a single FUNCTION_DECL (and a single DECL_UID), add the default
argument when the declaration is encountered in g, and then remove the default
argument when we exit that scope.  This example shows why you can't just keep
calling duplicate_decls; you can actually change the values of the default
arguments in different scopes, and, in scopes with no default argument
declared, the user must supply all arguments.

Default arguments are only part of the problem; the same issue applies to
things like:

  extern int a[];
  void f() { 
    extern int a[10];
  }

It will not be particularly entertaining to fix this in the C++ front-end,
though it is indeed something that should be done.  It's probably doable for
4.2, but I'd think it to be a very risk change for 4.1. 

Is there a work-around in the middle end that can be applied on the 4.1 branch?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26757

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.



Reply to: