This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17161] failure to diagnose an ill-formed instantiation on a local type


------- Additional Comments From bangerth at dealii dot org  2004-08-24 03:02 -------
Funny, actually. Consider this case: 
--------------- 
struct S { 
    void foo (unsigned long); 
    template <class T> void foo (T); 
}; 
 
enum E1 { e1 }; 
 
int main () 
{ 
  enum E2 { e2 }; 
  S().foo (e1); 
  S().foo (e2); 
} 
--------------------- 
Compiled with 3.4 and mainline, let's inspect the symbols: 
 
g/x> nm -C x.o 
         U __gxx_personality_v0 
00000000 T main 
         U S::foo(unsigned long) 
         U void S::foo<E1>(E1) 
 
So it uses the unsigned int version for the local type, and the template 
version for the global type. On could even make a case for this behavior 
(although I think that this is not the intent of the standard): since E2 
is a local type, it can't match the template function, which is therefore 
removed from the overload set, and the compiler then makes the conversion 
to unsigned long. Note that indeed the compiler says that there is no 
match if the non-template version of S::foo is removed, which would be 
consistent with this behavior. 
 
W. 
 

-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]