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++/6424] [DR 339] sizeof() with overload resolution


------- Additional Comments From giovannibajo at libero dot it  2004-08-09 15:28 -------
(In reply to comment #9)

> For example, this code is valid: 
> ----------------- 
> template <int> struct S {}; 
>  
> template <typename T> 
> S<sizeof(T)> foo (T); 
>  
> template <typename T> 
> S<sizeof(T)*2/2> foo (T); 
> ----------------- 
> However, when you want to call these functions, you get an ambiguity. 

Yes, but you must be able to define those two functions in two different 
translation units, instantiate them, and link the whole program without getting 
a symbol conflict.

> Do you an example where it would lead to confusion if the return expression 
> would be constant folded? 

Last time I asked this to Mark, the explanation was that it was too hard to 
describe *exactly* in the ABI specification what had to be folded and what had 
not. Plus, you would force compilers to do things not required by the C++ 
standard (which says, IIRC, that we are not forced to understand that foo(A<2>) 
and foo(A<1+1>) are the same declaration -- but notice I don't have the 
standard handy now), so in the end the best solution was to just mangle the 
unfolded expression.


-- 


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


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