[Bug c++/6424] [DR 339] sizeof() with overload resolution

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Mon Aug 9 14:58:00 GMT 2004


------- Additional Comments From bangerth at dealii dot org  2004-08-09 14:58 -------
This is getting off-topic, but maybe you have a short answer anyway: 
 
> For functions templates, the situation is radically different because 
> the expressions involved in function template declarations are part of 
> its signature.  And you can get function templates with "neighboor" 
> signatures co-existing in the same translation unit, without violating 
> the ODR.  
 
I understand that the return type is important for things like SFINAE, 
in order to decide which function to actually call. However, once this 
is decided, there needs to be exactly one instance, with a presumably 
unique signature, constants being folded or not. 
 
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. Do 
you an example where it would lead to confusion if the return expression 
would be constant folded? 
 
W. 

-- 


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



More information about the Gcc-bugs mailing list