This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch/RFC] PR 71569 ("[6/7/8 regression] Crash: External definition of template member from template struct")
- From: Jason Merrill <jason at redhat dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 28 Feb 2018 11:24:25 -0500
- Subject: Re: [C++ Patch/RFC] PR 71569 ("[6/7/8 regression] Crash: External definition of template member from template struct")
- Authentication-results: sourceware.org; auth=none
- References: <aa31f8c8-57ff-61ef-1214-060860079878@oracle.com> <CADzB+2nXWD0EQGHgPw5=mW_RPyv2GW8SMwQE7JPu+at6WJC2zA@mail.gmail.com> <eb46ce43-bb46-ba08-6923-06bd17d87755@oracle.com>
On Wed, Feb 28, 2018 at 11:18 AM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> On 28/02/2018 16:53, Jason Merrill wrote:
>> On Wed, Feb 28, 2018 at 9:36 AM, Paolo Carlini <paolo.carlini@oracle.com>
>> wrote:
>>>
>>> in this P2 ICE on invalid we fail to diagnose an ill-formed variable
>>> template partial specialization and the assert at the beginning of
>>> determine_specialization triggers. Indeed, we didn't diagnose the problem
>>> via check_specialization_scope (there are no template <>, thus
>>> begin_specialization isn't involved). Simply adding a specific check to
>>> check_explicit_specialization exactly when we recognize a variable template
>>> partial specialization seems a safe thing to do and passes testing. Not sure
>>> if the test itself is as simple as possible or is better done somewhere
>>> else...
>>
>> Hmm, this doesn't look like the user intended to write a partial
>> specialization, but rather that they were trying to define the member
>> template and wrote the template arguments out by mistake.
>
> I see your point. If I understand correctly, in such cases clang somehow
> talks about both possibilities:
>
> error: variable template partial specialization does not specialize any
> template argument; to define the primary template, remove the template
> argument list
>
> What do you think, should we do something similar?
Sounds good.
> (by the way, yesterday
> got a bit confused because in other vaguely related cases clang also has
> this kind of two-part error message and we don't. Eg, I cooked up:
>
> template <class T>
> class Foo
> {
> template <class U>
> class Bar;
> };
>
> template<class T>
> template<class U>
> class Foo<T>::Bar<U>;
And the same would be good for this example.
Jason