public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "davveston at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99697] New: ICE for class template partial specialization over non-template (structural class template) parameter of deduced class type
Date: Sun, 21 Mar 2021 16:45:14 +0000	[thread overview]
Message-ID: <bug-99697-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 99697
           Summary: ICE for class template partial specialization over
                    non-template (structural class template) parameter of
                    deduced class type
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: davveston at gmail dot com
  Target Milestone: ---

The following program:

// -----------------------------------
// prog.cc
template<int N> struct S {};
template<S s>   struct U {};
template<typename>  struct V;

template<S s> struct V<U<s<0>> {}; // #1: ICE

int main() {}
// -----------------------------------

compiled with gcc HEAD 11.0.1 20210320 (experimental) and the following command

 g++ prog.cc -Wall -Wextra -std=gnu++2b

results in the following ICE (segfault) at #1:

// -----------------------------------
prog.cc:5:28: internal compiler error: Segmentation fault
    5 | template<S s> struct V<U<s<0>> {}; // ICE
      |                            ^
0xca91ff crash_signal
        ../../source/gcc/toplev.c:327
0x63a207 resolve_args(vec<tree_node*, va_gc, vl_embed>*, int)
        ../../source/gcc/cp/call.c:4548
0x78a764 do_class_deduction
        ../../source/gcc/cp/pt.c:29332
0x78a764 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ../../source/gcc/cp/pt.c:29509
0x798c37 convert_template_argument
        ../../source/gcc/cp/pt.c:8491
0x79a19b convert_template_argument
        ../../source/gcc/cp/pt.c:8264
0x79a19b coerce_template_parms
        ../../source/gcc/cp/pt.c:8995
0x79b411 lookup_template_class_1
        ../../source/gcc/cp/pt.c:9833
0x79c3ec lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ../../source/gcc/cp/pt.c:10237
0x7c028d finish_template_type(tree_node*, tree_node*, int)
        ../../source/gcc/cp/semantics.c:3563
0x75f603 cp_parser_template_id
        ../../source/gcc/cp/parser.c:17458
0x75f86b cp_parser_class_name
        ../../source/gcc/cp/parser.c:24685
0x75783a cp_parser_qualifying_entity
        ../../source/gcc/cp/parser.c:7002
0x75783a cp_parser_nested_name_specifier_opt
        ../../source/gcc/cp/parser.c:6684
0x76c30f cp_parser_simple_type_specifier
        ../../source/gcc/cp/parser.c:18851
0x74cd8d cp_parser_type_specifier
        ../../source/gcc/cp/parser.c:18509
0x75d323 cp_parser_type_specifier_seq
        ../../source/gcc/cp/parser.c:23360
0x75bba4 cp_parser_type_id_1
        ../../source/gcc/cp/parser.c:23163
0x75de83 cp_parser_template_type_arg
        ../../source/gcc/cp/parser.c:23268
0x75dfaf cp_parser_template_argument
        ../../source/gcc/cp/parser.c:17908
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
// -----------------------------------

I think the partial specialization at #1 can never be used as the non-type
template parameter 's' of deduced class type can never be deduced, such that
the correct behaviour should arguably be to reject the program as ill-formed
(at #1).

Demo: https://wandbox.org/permlink/ufm4B9uIn8dgHYAI

             reply	other threads:[~2021-03-21 16:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 16:45 davveston at gmail dot com [this message]
2021-04-30 21:02 ` [Bug c++/99697] " mpolacek at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99697-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).