This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/6424] [DR 339] sizeof() with overload resolution
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Aug 2004 15:28:24 -0000
- Subject: [Bug c++/6424] [DR 339] sizeof() with overload resolution
- References: <20020423071601.6424.jens.maurer@gmx.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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