[Bug c++/92735] unused member variable causes code to compile for member to function for undefined function

2020-01-30 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92735

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-01-30
 CC||marxin at gcc dot gnu.org
 Ever confirmed|0   |1

[Bug c++/92735] unused member variable causes code to compile for member to function for undefined function

2019-12-03 Thread marcpawl at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92735

--- Comment #4 from Marc Pawlowsky  ---
(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 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::hello.

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

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

[Bug c++/92735] unused member variable causes code to compile for member to function for undefined function

2019-12-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92735

--- Comment #3 from Jonathan Wakely  ---
Related to http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1396

[Bug c++/92735] unused member variable causes code to compile for member to function for undefined function

2019-12-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92735

--- Comment #2 from Jonathan Wakely  ---
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 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::hello.

[Bug c++/92735] unused member variable causes code to compile for member to function for undefined function

2019-12-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92735

--- Comment #1 from Jonathan Wakely  ---
(In reply to Marc Pawlowsky from comment #0)
> on a related not I sent to clang bug report where if value is not static the
> code will compile.

https://bugs.llvm.org/show_bug.cgi?id=44175 (I think that's not a bug).