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

            Bug ID: 115919
           Summary: ICE: in tsubst_expr, at cp/pt.cc:20300
           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 tsubst_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 pom.ii


template<int i>
class A
{
public:
    static double const VAL = 0.5;

    enum
    {
 COS = (int)(A::VAL)
    };
};

int main()
{
    A<5>::COS;
    return 0;
}


*******************************************************************************
Command Lines:
# g++ pom.ii  -O2 -Wall -Wextra -pedantic -std=c++17 -fno-exceptions -fno-rtti
-fstrict-aliasing -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align
-Woverloaded-virtual -Wconversion -Wsign-conversion -Wduplicated-cond
-Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast
-Wdouble-promotion -Wformat=2 -o pom.o
pom.cpp:5:25: error: ‘constexpr’ needed for in-class initialization of static
data member ‘const double A<i>::VAL’ of non-integral type [-fpermissive]
pom.cpp:9:20: warning: use of old-style cast to ‘int’ [-Wold-style-cast]
pom.cpp: In instantiation of ‘class A<5>’:
pom.cpp:15:9:   required from here
pom.cpp:5:25: error: ‘constexpr’ needed for in-class initialization of static
data member ‘const double A<5>::VAL’ of non-integral type [-fpermissive]
pom.cpp:9:8: internal compiler error: in tsubst_expr, at cp/pt.cc:20306
0x82df47 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:20306
0xcdf0fe tsubst_enum
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:27699
0xcdf0fe lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:10496
0xcd2cd0 tsubst(tree_node*, tree_node*, int, tree_node*)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:16265
0xccf2d4 tsubst_decl
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:15435
0xcef0d0 instantiate_class_template(tree_node*)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:12572
0xd43e90 complete_type(tree_node*)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/typeck.cc:138
0xc6bc3a cp_parser_nested_name_specifier_opt
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:7271
0xc7a7b7 cp_parser_simple_type_specifier
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:20576
0xc53411 cp_parser_type_specifier
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:20227
0xc551ed cp_parser_decl_specifier_seq
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:16675
0xc56588 cp_parser_simple_declaration
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:15831
0xc7cb60 cp_parser_declaration_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:14944
0xc84b7e cp_parser_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:12897
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
0xc835be cp_parser_function_definition_from_specifiers_and_declarator
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32820
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/KvhjM1Ese

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

Reply via email to