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

            Bug ID: 115510
           Summary: ICE : Segmentation fault  in build_new_method_call
                    and finish_call_expr
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---
            Target: x86_64

*******************************************************************************
The compiler produces an internal error during build_new_method_call  and
finish_call_expr when compiling the provided code with the specified options. 
The issue can also be reproduced on Compiler Explorer.

*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /root/gdbtest/gcc/obj/../gcc/configure
--prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240509 (experimental) (GCC) 
*******************************************************************************
Program:
# cat main.ii

class a {        b(({
    a &c = ;
    class {            d(){
      c.b()
    }}}}

*******************************************************************************
Command Lines:
# g++ main.ii -std=c++2a -Wall -Wextra -pedantic -fsanitize=address,undefined
-fno-omit-frame-pointer -g -O2 -Wshadow -Wnon-virtual-dtor -Wold-style-cast
-Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion
-Wsign-conversion -Wmisleading-indentation -Wduplicated-cond
-Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast
-Wdouble-promotion -Wformat=2 -c -o main.o
main.ii:1:20: error: expected identifier before ‘(’ token
    1 | class a {        b(({
      |                    ^
main.ii:1:21: error: expected ‘)’ before ‘{’ token
    1 | class a {        b(({
      |                    ~^
      |                     )
main.ii:1:21: error: expected ‘)’ before ‘{’ token
    1 | class a {        b(({
      |                   ~ ^
      |                     )
main.ii:1:18: error: ISO C++ forbids declaration of ‘b’ with no type
[-fpermissive]
    1 | class a {        b(({
      |                  ^
main.ii:5:9: error: expected ‘;’ after class definition
    5 |     }}}}
      |         ^
      |         ;
main.ii: In member function ‘int a::b(...)’:
main.ii:2:12: error: expected primary-expression before ‘;’ token
    2 |     a &c = ;
      |            ^
main.ii:3:24: error: ISO C++ forbids declaration of ‘d’ with no type
[-fpermissive]
    3 |     class {            d(){
      |                        ^
main.ii:5:7: error: expected ‘;’ after class definition
    5 |     }}}}
      |       ^
      |       ;
main.ii: In member function ‘int a::b(...)::<unnamed class>::d()’:
main.ii:4:10: error: use of local variable with automatic storage from
containing function
    4 |       c.b()
      |       ~~~^~
main.ii:2:8: note: ‘a& c’ declared here
    2 |     a &c = ;
      |        ^
main.ii:4:10: internal compiler error: Segmentation fault
    4 |       c.b()
      |       ~~~^~
0x13a93af crash_signal
        /root/gdbtest/gcc/obj/../gcc/gcc/toplev.cc:319
0xaaac6b build_this_conversion
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/call.cc:2386
0xaab84d add_function_candidate
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/call.cc:2564
0xaad031 add_candidates
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/call.cc:6724
0xab75c8 add_candidates
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/call.cc:6536
0xab75c8 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/call.cc:11723
0xd0b682 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/semantics.cc:2989
0xc69c1f cp_parser_postfix_expression
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:8178
0xc44eeb cp_parser_binary_expression
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:10398
0xc45c54 cp_parser_assignment_expression
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:10742
0xc461f4 cp_parser_expression
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:10909
0xc4c927 cp_parser_expression_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13175
0xc8515b cp_parser_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:12952
0xc59807 cp_parser_statement_seq_opt
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13427
0xc59a2f cp_parser_compound_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13281
0xc7ccd5 cp_parser_function_body
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:26072
0xc7ccd5 cp_parser_ctor_initializer_opt_and_function_body
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:26123
0xc8241e cp_parser_function_definition_after_declarator
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32903
0xc838a4 cp_parser_late_parsing_for_member
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:33882
0xc54a44 cp_parser_class_specifier
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:27279
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


*******************************************************************************

Also ICE on trunk, compiler explorer:https://godbolt.org/z/WdnP8Y66E

*******************************************************************************

Reply via email to