[Bug c++/72842] non-type template-parameter of type void
wjwray at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Dec 5 16:34:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72842
Will Wray <wjwray at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wjwray at gmail dot com
--- Comment #8 from Will Wray <wjwray at gmail dot com> ---
Reporting a (non-variadic) case here in which gcc incorrectly accepts void,
and now also accepts class types not satisfying the requirements for a
class type non-type template parameter (now they are implemented on trunk).
https://godbolt.org/z/fjFzMm
template <typename T,T> struct TT;
template <typename T, template <typename,T> class TT> struct TTT {};
TTT<void,TT> x;
GCC accepts the variable declaration
(or explicit instantiation template struct TTT<void,TT>; )
Clang rejects with:
error: a non-type template parameter cannot have type 'void'
template <typename T, template <typename,T> class TT> struct TTT {};
^
This is easy to CONFIRM via the compiler explorer link above.
Also
With class-type non-type template parameters now in gcc trunk
GCC incorrectly accepts this:
struct NotNTTP { int mutable i; };
TTT<NotNTTP,TT> c;
https://godbolt.org/z/jfioyB
(The compiler explorer link implements a constraint to test
if a type fits the requirements of a non-type template parameter,
otherwise hard to implement without relying on default construction)
Perhaps this should be a new bug as the title is specific to void.
More information about the Gcc-bugs
mailing list