public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108245] New: parser segv
@ 2022-12-28 18:08 rscohn2 at gmail dot com
  2022-12-28 18:17 ` [Bug c++/108245] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rscohn2 at gmail dot com @ 2022-12-28 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108245
           Summary: parser segv
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rscohn2 at gmail dot com
  Target Milestone: ---

Created attachment 54161
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54161&action=edit
reproducer

The attached program has a syntax error that causes a segv in the parser. 

Here is the compiler version:

g++-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0

It fails the same way with g++ 12.2 in compiler exporer:

https://godbolt.org/z/zKjYE44WW

And here is the error.

rscohn1@rscohn1-mobl1:test$ g++-12 -c short.ii
In file included from /usr/include/c++/12/type_traits:38,
                 from /usr/include/c++/12/bits/stl_pair.h:60,
                 from /usr/include/c++/12/tuple:38,
                 from short.cpp:1:
/usr/include/x86_64-linux-gnu/c++/12/bits/c++config.h: In function ‘auto
local_zipped_range()’:
/usr/include/x86_64-linux-gnu/c++/12/bits/c++config.h:298:36: internal compiler
error: Segmentation fault
  298 |   typedef __SIZE_TYPE__         size_t;
      |                                    ^~~~
0xd910e3 crash_signal
        ../../src/gcc/toplev.cc:322
0x7fd3ecb7451f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x81ca65 tsubst_decl
        ../../src/gcc/cp/pt.cc:14899
0x7e6f97 cp_parser_parameter_declaration
        ../../src/gcc/cp/parser.cc:24868
0x7e7512 cp_parser_parameter_declaration_list
        ../../src/gcc/cp/parser.cc:24564
0x7e78c4 cp_parser_parameter_declaration_clause
        ../../src/gcc/cp/parser.cc:24491
0x7e885f cp_parser_lambda_declarator_opt
        ../../src/gcc/cp/parser.cc:11579
0x7cf854 cp_parser_lambda_expression
        ../../src/gcc/cp/parser.cc:11105
0x7d03d3 cp_parser_primary_expression
        ../../src/gcc/cp/parser.cc:5698
0x7d2fed cp_parser_postfix_expression
        ../../src/gcc/cp/parser.cc:7654
0x7bc7c6 cp_parser_binary_expression
        ../../src/gcc/cp/parser.cc:10035
0x7bcfce cp_parser_assignment_expression
        ../../src/gcc/cp/parser.cc:10339
0x7beaf9 cp_parser_constant_expression
        ../../src/gcc/cp/parser.cc:10642
0x7beb91 cp_parser_initializer_clause
        ../../src/gcc/cp/parser.cc:25223
0x7c1b7c cp_parser_initializer
        ../../src/gcc/cp/parser.cc:25163
0x7ef733 cp_parser_init_declarator
        ../../src/gcc/cp/parser.cc:22773
0x7cbb28 cp_parser_simple_declaration
        ../../src/gcc/cp/parser.cc:15280
0x7cd750 cp_parser_declaration_statement
        ../../src/gcc/cp/parser.cc:14361
0x7cdf3c cp_parser_statement
        ../../src/gcc/cp/parser.cc:12446
0x7cee5d cp_parser_statement_seq_opt
        ../../src/gcc/cp/parser.cc:12850
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
rscohn1@rscohn1-mobl1:test$

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

* [Bug c++/108245] parser segv
  2022-12-28 18:08 [Bug c++/108245] New: parser segv rscohn2 at gmail dot com
@ 2022-12-28 18:17 ` pinskia at gcc dot gnu.org
  2022-12-28 18:19 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-28 18:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Uninclude version:
#include <tuple>

auto local_zipped_range() {
    int b[10];
    auto zip_it = [=](std::size_t auto... I) {
      return std::tuple(b[I], b[I])...);
    };
    return zip_it(std::make_index_sequence<std::size(b)>());
}

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

* [Bug c++/108245] parser segv
  2022-12-28 18:08 [Bug c++/108245] New: parser segv rscohn2 at gmail dot com
  2022-12-28 18:17 ` [Bug c++/108245] " pinskia at gcc dot gnu.org
@ 2022-12-28 18:19 ` pinskia at gcc dot gnu.org
  2022-12-28 18:23 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-28 18:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
typedef int mytype;
void h() {
    [=](mytype auto... I) { };
}

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

* [Bug c++/108245] parser segv
  2022-12-28 18:08 [Bug c++/108245] New: parser segv rscohn2 at gmail dot com
  2022-12-28 18:17 ` [Bug c++/108245] " pinskia at gcc dot gnu.org
  2022-12-28 18:19 ` pinskia at gcc dot gnu.org
@ 2022-12-28 18:23 ` pinskia at gcc dot gnu.org
  2022-12-28 18:28 ` [Bug c++/108245] ICE with invalid variable auto arguments and supplying an extra type pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-28 18:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|                            |2022-12-28
      Known to fail|                            |10.4.0, 11.3.0, 4.9.0,
                   |                            |5.1.0, 6.1.0, 7.1.0, 8.1.0,
                   |                            |9.5.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

For my reduced testcase, clang reports an error message:
<source>:3:16: error: cannot combine with previous 'type-name' declaration
specifier
    [=](mytype auto... I) { };
               ^
<source>:3:20: error: type 'mytype' (aka 'int') of function parameter pack does
not contain any unexpanded parameter packs
    [=](mytype auto... I) { };
        ~~~~~~~~~~~^~~~~
<source>:3:5: warning: expression result unused [-Wunused-value]
    [=](mytype auto... I) { };
    ^~~~~~~~~~~~~~~~~~~~~~~~~

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

* [Bug c++/108245] ICE with invalid variable auto arguments and supplying an extra type
  2022-12-28 18:08 [Bug c++/108245] New: parser segv rscohn2 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-12-28 18:23 ` pinskia at gcc dot gnu.org
@ 2022-12-28 18:28 ` pinskia at gcc dot gnu.org
  2023-01-06  7:13 ` pinskia at gcc dot gnu.org
  2023-09-26 17:11 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-28 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|parser segv                 |ICE with invalid variable
                   |                            |auto arguments and
                   |                            |supplying an extra type

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced further (a C++20 since C++20 expanded the use of auto to functions
rather than just lambdas but still invalid):
```
typedef int mytype;
void f(mytype auto... I) {}
```

Note without the variable argument auto, GCC rejects the code:
<source>:2:8: error: two or more data types in declaration of 'I'
    2 | void f(mytype auto I) {}
      |        ^~~~~~

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

* [Bug c++/108245] ICE with invalid variable auto arguments and supplying an extra type
  2022-12-28 18:08 [Bug c++/108245] New: parser segv rscohn2 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-12-28 18:28 ` [Bug c++/108245] ICE with invalid variable auto arguments and supplying an extra type pinskia at gcc dot gnu.org
@ 2023-01-06  7:13 ` pinskia at gcc dot gnu.org
  2023-09-26 17:11 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-06  7:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lyubomir.filipov at amusnet dot co
                   |                            |m

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 108302 has been marked as a duplicate of this bug. ***

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

* [Bug c++/108245] ICE with invalid variable auto arguments and supplying an extra type
  2022-12-28 18:08 [Bug c++/108245] New: parser segv rscohn2 at gmail dot com
                   ` (4 preceding siblings ...)
  2023-01-06  7:13 ` pinskia at gcc dot gnu.org
@ 2023-09-26 17:11 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-26 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stevenxia990430 at gmail dot com

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111596 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2023-09-26 17:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-28 18:08 [Bug c++/108245] New: parser segv rscohn2 at gmail dot com
2022-12-28 18:17 ` [Bug c++/108245] " pinskia at gcc dot gnu.org
2022-12-28 18:19 ` pinskia at gcc dot gnu.org
2022-12-28 18:23 ` pinskia at gcc dot gnu.org
2022-12-28 18:28 ` [Bug c++/108245] ICE with invalid variable auto arguments and supplying an extra type pinskia at gcc dot gnu.org
2023-01-06  7:13 ` pinskia at gcc dot gnu.org
2023-09-26 17:11 ` 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).