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

--- Comment #4 from Marc Pawlowsky <marcpawl at gmail dot com> ---
(In reply to Jonathan Wakely from comment #2)
> For the case reported here, Clang and EDG do reject it, but I'm not yet
> convinced GCC is wrong to accept it.
> 
> The implicit instantiation of is_Foo<Bad> causes:
> 
> "the implicit instantiation of the declarations, but not of the definitions,
> of the non-deleted class member functions, member classes, scoped member
> enumerations, static data members, member templates, and friends;"
> 
> and:
> 
> "in particular, the initialization (and any associated side effects) of a
> static data member does not occur unless the static data member is itself
> used in a way that requires the definition of the static data member to
> exist."
> 
> Nothing requires the instantiation of is_Foo<Bad>::hello.

FYI, Forcing the use of hello does cause a compile time error.
template <typename T>
struct is_Foo {
    using hello_fn_t = void (T::*)(int);
    constexpr static void (T::*hello)(int) = &T::hello;
    static constexpr bool value=(!!hello);
};
source>:16:46: error: 'hello' is not a member of 'Bad'

   16 |     constexpr static void (T::*hello)(int) = &T::hello;

Reply via email to