diff mbox

[c++] : Fix PR/61198: Crash when selecting specializations through aliases.

Message ID CAEwic4bQEs_=cL+Kx2N42p=SmfEHx-97+Smhf6+qn+Kcwp4hUw@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Dec. 19, 2014, 4 p.m. UTC
2014-12-19 0:14 GMT+01:00 Jason Merrill <jason@redhat.com>:
> On 12/18/2014 01:16 PM, Kai Tietz wrote:
>>
>> Well, in general I would have assumed to be able to get alias decl of
>> tmpl. Wasn't able to find a simple way to get it. So, by looking into
>> source I found that most cases handling args > tmpl-args by using
>> inner_most_template_args instead. Defaulting to
>> innermost_template_args looks indeed a bit wrong, but seemed to work.
>
>
> It's wrong, it just papers over the bug.  There shouldn't be a mismatch at
> this point.
>
> The problem seems to be that most_general_template isn't actually returning
> the most general template, so we're trying to instantiate the
> partially-instantiated alias template with a full set of arguments: thus the
> mismatch.
>
> Jason
>

Yes, in most_general_template we don't loop for TEMPLATE_DECL_ALIAS.

ChangeLog

2014-12-19 Kai Tietz  <ktietz@redhat.com>

      * pt.c (most_general_template): Don't break for template-alias.

Ok for apply (with testcase as posted before)?

Regards,
Kai

Comments

Jason Merrill Dec. 19, 2014, 4:28 p.m. UTC | #1
OK, thanks.

Jason
H.J. Lu Dec. 19, 2014, 4:46 p.m. UTC | #2
On Fri, Dec 19, 2014 at 8:00 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 2014-12-19 0:14 GMT+01:00 Jason Merrill <jason@redhat.com>:
>> On 12/18/2014 01:16 PM, Kai Tietz wrote:
>>>
>>> Well, in general I would have assumed to be able to get alias decl of
>>> tmpl. Wasn't able to find a simple way to get it. So, by looking into
>>> source I found that most cases handling args > tmpl-args by using
>>> inner_most_template_args instead. Defaulting to
>>> innermost_template_args looks indeed a bit wrong, but seemed to work.
>>
>>
>> It's wrong, it just papers over the bug.  There shouldn't be a mismatch at
>> this point.
>>
>> The problem seems to be that most_general_template isn't actually returning
>> the most general template, so we're trying to instantiate the
>> partially-instantiated alias template with a full set of arguments: thus the
>> mismatch.
>>
>> Jason
>>
>
> Yes, in most_general_template we don't loop for TEMPLATE_DECL_ALIAS.
>
> ChangeLog
>
> 2014-12-19 Kai Tietz  <ktietz@redhat.com>
>
>       * pt.c (most_general_template): Don't break for template-alias.
>
> Ok for apply (with testcase as posted before)?
>

Did you forget to check in the testcase?
Kai Tietz Dec. 19, 2014, 4:48 p.m. UTC | #3
2014-12-19 17:46 GMT+01:00 H.J. Lu <hjl.tools@gmail.com>:
>
> Did you forget to check in the testcase?

No, see rev 218956.

> --
> H.J.
Paolo Carlini Dec. 19, 2014, 5:22 p.m. UTC | #4
Hi,

On 12/19/2014 05:48 PM, Kai Tietz wrote:
> 2014-12-19 17:46 GMT+01:00 H.J. Lu <hjl.tools@gmail.com>:
>> Did you forget to check in the testcase?
> No, see rev 218956.
But you want to move it to the cpp0x directory, and likely name it 
alias-decl-45.C or something similar. In the template directory is also 
compiled in c++98 mode and is failing for everybody.

Paolo.
Kai Tietz Dec. 19, 2014, 6:04 p.m. UTC | #5
2014-12-19 18:22 GMT+01:00 Paolo Carlini <paolo.carlini@oracle.com>:
> Hi,
>
>
> On 12/19/2014 05:48 PM, Kai Tietz wrote:
>>
>> 2014-12-19 17:46 GMT+01:00 H.J. Lu <hjl.tools@gmail.com>:
>>>
>>> Did you forget to check in the testcase?
>>
>> No, see rev 218956.
>
> But you want to move it to the cpp0x directory, and likely name it
> alias-decl-45.C or something similar. In the template directory is also
> compiled in c++98 mode and is failing for everybody.
>
> Paolo.

Ok, renamed and moved.

Kai
diff mbox

Patch

Index: pt.c
==================================================================
--- pt.c        (Revision 218897)
+++ pt.c        (Arbeitskopie)
@@ -19207,6 +19207,7 @@  most_general_template (tree decl)
        break;

       if (CLASS_TYPE_P (TREE_TYPE (decl))
+         && !TYPE_DECL_ALIAS_P (TYPE_NAME (TREE_TYPE (decl)))
          && CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl)))
        break;