This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/10126] ICE in convert_nontype_argument on using overload resolution in template args
- From: "jason at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Dec 2003 05:51:23 -0000
- Subject: [Bug c++/10126] ICE in convert_nontype_argument on using overload resolution in template args
- References: <20030318001600.10126.marco.franzen@bigfoot.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From jason at gcc dot gnu dot org 2003-12-02 05:51 -------
This testcase is ill-formed:
5.3.1 Unary operators [expr.unary.op]
2 The result of the unary & operator is a pointer to its operand. The
operand shall be an lvalue or a qualified-id....
For a qualified-id,
if the member is a static member of type "T", the type of the result
is plain "pointer to T." If the member is a nonstatic member of class
C of type T, the type of the result is "pointer to member of class C
of type T." [Example:
struct A { int i; };
struct B : A { };
... &B::i ... // has type int A::*
--end example]
14.3.2 Template non-type arguments [temp.arg.nontype]
-- For a non-type template-parameter of type pointer to member
function, no conversions apply. If the template-argument
represents a set of overloaded member functions, the matching
member function is selected from the set (_over.over_).
For better or worse, in this case worse, &Strawberry::I has type pointer to
member function of Fruit, not of Strawberry, and no conversion is done to make
it a pointer to member function of Strawberry. To make it work, you need to add
an explicit downcast:
dish.Get<(int const& (Strawberry::*fun)() const)&Strawberry::I>();
Dave, your testcase in 13040 is similarly ill-formed.
I'm not arguing that these rules make sense, but that is in fact what they say.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords|ice-on-valid-code |ice-on-invalid-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10126