public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95927] New: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701
@ 2020-06-27  2:21 haoxintu at gmail dot com
  2020-07-03  4:17 ` [Bug c++/95927] " haoxintu at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-27  2:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95927
           Summary: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC ICE.

$cat bug.cc
class {
struct a < struct { b ( {

$g++ bug.cc
bug.cc:2:8: error: ‘a’ is not a class template
    2 | struct a < struct { b ( {
      |        ^
bug.cc:2:19: error: types may not be defined in template arguments
    2 | struct a < struct { b ( {
      |                   ^
bug.cc:2:25: error: expected identifier before ‘{’ token
    2 | struct a < struct { b ( {
      |                         ^
bug.cc:2:24: error: expected ‘)’ before ‘{’ token
    2 | struct a < struct { b ( {
      |                       ~^~
      |                        )
bug.cc:2:21: error: ISO C++ forbids declaration of ‘b’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
    2 | struct a < struct { b ( {
      |                     ^
bug.cc:3: error: expected ‘}’ at end of input
bug.cc:2:19: note: to match this ‘{’
    2 | struct a < struct { b ( {
      |                   ^
bug.cc:3: error: expected template-argument at end of input
bug.cc:3: error: expected ‘>’ at end of input
bug.cc:3: error: expected ‘{’ or ‘:’ at end of input
bug.cc:3: error: expected ‘{’ at end of input
bug.cc:3: error: expected unqualified-id at end of input
bug.cc:3: error: expected ‘}’ at end of input
bug.cc:1:7: note: to match this ‘{’
    1 | class {
      |       ^
bug.cc:3: internal compiler error: in cp_lexer_new_from_tokens, at
cp/parser.c:701
0x641d4d cp_parser_push_lexer_for_tokens
        ../../gcc/cp/parser.c:701
0x9c2bc5 cp_parser_late_parsing_for_member
        ../../gcc/cp/parser.c:29944
0x9a0ccb cp_parser_class_specifier_1
        ../../gcc/cp/parser.c:24230
0x9a1aa3 cp_parser_class_specifier
        ../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14410
0x9a35c1 cp_parser_simple_declaration
        ../../gcc/cp/parser.c:13664
0x9cc926 cp_parser_declaration
        ../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
        ../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
        ../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1190
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.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/95927] ICE in cp_lexer_new_from_tokens, at cp/parser.c:701
  2020-06-27  2:21 [Bug c++/95927] New: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701 haoxintu at gmail dot com
@ 2020-07-03  4:17 ` haoxintu at gmail dot com
  2020-07-08 21:50 ` mpolacek at gcc dot gnu.org
  2021-12-29  0:24 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-03  4:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Haoxin Tu <haoxintu at gmail dot com> ---
Add a more meaningful case.


$cat p.cc
template <class> struct a {};
class A {
    struct a < struct x { void b ( ){}} >;
};

$g++ p.cc
p.cc:3:25: error: types may not be defined in template arguments
    3 |     struct a < struct x { void b ( ){}} >;
      |                         ^
p.cc:3:40: error: expected ‘;’ after struct definition
    3 |     struct a < struct x { void b ( ){}} >;
      |                                        ^
      |                                        ;
p.cc:3:39: error: expected template-argument before ‘;’ token
    3 |     struct a < struct x { void b ( ){}} >;
      |                                       ^
p.cc:3:39: error: expected ‘>’ before ‘;’ token
p.cc:3:5: error: ‘struct a<A::x>’ redeclared with different access
    3 |     struct a < struct x { void b ( ){}} >;
      |     ^~~~~~
p.cc:3:41: error: expected unqualified-id before ‘>’ token
    3 |     struct a < struct x { void b ( ){}} >;
      |                                         ^
p.cc:4:1: internal compiler error: in cp_lexer_new_from_tokens, at
cp/parser.c:701
    4 | };
      | ^
0x6adadc cp_parser_push_lexer_for_tokens
        ../../gcc/cp/parser.c:701
...


While in Clang
$clang++ p.cc
p.cc:3:23: error: 'x' cannot be defined in a type specifier
    struct a < struct x { void b ( ){}} >;
                      ^
1 error generated.

I guess Clang is performed better when parsing this case. GCC emits a lot of
error messages even throw an ICE, while Clang just emits one.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/95927] ICE in cp_lexer_new_from_tokens, at cp/parser.c:701
  2020-06-27  2:21 [Bug c++/95927] New: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701 haoxintu at gmail dot com
  2020-07-03  4:17 ` [Bug c++/95927] " haoxintu at gmail dot com
@ 2020-07-08 21:50 ` mpolacek at gcc dot gnu.org
  2021-12-29  0:24 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-08 21:50 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-07-08
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P5
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/95927] ICE in cp_lexer_new_from_tokens, at cp/parser.c:701
  2020-06-27  2:21 [Bug c++/95927] New: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701 haoxintu at gmail dot com
  2020-07-03  4:17 ` [Bug c++/95927] " haoxintu at gmail dot com
  2020-07-08 21:50 ` mpolacek at gcc dot gnu.org
@ 2021-12-29  0:24 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-29  0:24 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 39751.

*** This bug has been marked as a duplicate of bug 39751 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-29  0:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-27  2:21 [Bug c++/95927] New: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701 haoxintu at gmail dot com
2020-07-03  4:17 ` [Bug c++/95927] " haoxintu at gmail dot com
2020-07-08 21:50 ` mpolacek at gcc dot gnu.org
2021-12-29  0:24 ` pinskia at gcc dot gnu.org

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).