[Bug c++/71879] Error in unevaluated context breaks SFINAE

inadgob at yahoo dot com gcc-bugzilla@gcc.gnu.org
Mon Jul 18 10:10:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71879

bogdan <inadgob at yahoo dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |inadgob at yahoo dot com

--- Comment #2 from bogdan <inadgob at yahoo dot com> ---
(In reply to Jonathan Wakely from comment #1)
> Taking the address of Foo::foo<Caller> instantiates it, which results in an
> error outside the immediate context, so you get an error not a substitution
> failure.

Yes, GCC tries to instantiate the definition of the specialization, but I don't
think it should.

[temp.inst]/3: Unless a function template specialization has been explicitly
instantiated or explicitly specialized, the function template specialization is
implicitly instantiated when the specialization is referenced in a context that
requires a function definition to exist. [...]

[temp.inst]/8: An implementation shall not implicitly instantiate a function
template, a variable template, a member template, a non-virtual member
function, a member class, or a static data member of a class template that does
not require instantiation. [...]

I don't think forming a pointer to a member function as an operand to decltype
like in this example should, by itself, require the function's definition to
exist; after all, we're only interested in the type. In this case, determining
it doesn't require deduction of any placeholder type or evaluation of any
constant expression. I don't see how the definition could influence the
resulting type.

In terms of odr-use, the template-id for the specialization appears as a
subexpression of an unevaluated operand, so it's not potentially evaluated, so
[basic.def.odr] doesn't require a definition.

The example works on Clang, EDG and MSVC, so none of them attempts to
instantiate the definition.


More information about the Gcc-bugs mailing list