[Bug c++/72842] non-type template-parameter of type void

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Mon Aug 8 21:24:00 GMT 2016


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

--- Comment #7 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Daniel Krügler from comment #5)
> (In reply to Barry Revzin from comment #4)
> > I'll just email. Instantiating foo<void> creates a function template with a
> > non-type template parameter of type void. That's not an allowed type of a
> > non-type template parameter, so I think it should be ill-formed.
> 
> It truely is ill-formed, but the question is whether an implementation is
> required to diagnose it. For the non-depending case the diagnostics is a
> hard requirement. But for the dependent case we have [temp.res] p8:
> 
> "The program is ill-formed, no diagnostic required, if:
> [..]
> — every valid specialization of a variadic template requires an empty
> template parameter pack, or [..]"
> 
> My argument is that this is the case we are entering here: Ill-formed, but
> no diagnostics required.

After a second look at your original foo template I need to correct myself a
bit, so let me be more precise:

1) Your second bar() example is ill-formed, no diagnostics required, as
explained above. But it is nonetheless diagnosed here (because the case is
simple).

2) Your original foo example is simply valid, because the pack is empty and so
there is no non-type template parameter of type void, as I described in my very
first response. For this example my [temp.res] quote doesn't hold, because one
can produce several other valid specializations of that template without an
empty parameter pack (e.g. when selecting T=int). Of-course it would still not
be valid to attempt to generate a non-empty pack expansion of the second
parameter using void or other types that are not valid as non-type parameters.


More information about the Gcc-bugs mailing list