[Bug c++/105756] New: ICE in cxx_eval_constant_expression at cp/constexpr.cc:7586: unexpected expression ‘ElemSize’ of kind template_parm_index

slyfox at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat May 28 06:50:16 GMT 2022


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

            Bug ID: 105756
           Summary: ICE in cxx_eval_constant_expression at
                    cp/constexpr.cc:7586: unexpected expression ‘ElemSize’
                    of kind template_parm_index
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Originally reported by tt_1 at https://bugs.gentoo.org/847601 on 0ad-0.0.25b
project.

I see two similar ICEs in bugzilla but not sure they are the happening in same
area. Here is the minimized example that seems to be buildable by clang:

  // $ cat RegExp.cpp.cpp
  template <int ElemSize> decltype(0 % ElemSize == 0) a;


$ g++ -o RegExp.o -c  -O2  RegExp.cpp.cpp
RegExp.cpp.cpp:1:47: internal compiler error: unexpected expression ‘ElemSize’
of kind template_parm_index
    1 | template <int ElemSize> decltype(0 % ElemSize == 0) a;
      |                                  ~~~~~~~~~~~~~^~~~
0xa39bb3 cxx_eval_constant_expression
        ../../gcc-13-20220522/gcc/cp/constexpr.cc:7586
0xa39eab cxx_eval_outermost_constant_expr
        ../../gcc-13-20220522/gcc/cp/constexpr.cc:7823
0xa3cc89 potential_constant_expression_1
        ../../gcc-13-20220522/gcc/cp/constexpr.cc:9272
0xa3d8a9 potential_constant_expression_1(tree_node*, bool, bool, bool, int)
        ../../gcc-13-20220522/gcc/cp/constexpr.cc:9548
0xa3d8a9 is_constant_expression(tree_node*)
        ../../gcc-13-20220522/gcc/cp/constexpr.cc:9605
0xa3d8a9 is_nondependent_constant_expression(tree_node*)
        ../../gcc-13-20220522/gcc/cp/constexpr.cc:9642
0xa3e83f maybe_constant_value(tree_node*, tree_node*, bool)
        ../../gcc-13-20220522/gcc/cp/constexpr.cc:8069
0xa6dea4 cp_fully_fold(tree_node*)
        ../../gcc-13-20220522/gcc/cp/cp-gimplify.cc:2353
0xa6dea4 cp_fully_fold(tree_node*)
        ../../gcc-13-20220522/gcc/cp/cp-gimplify.cc:2345
0xc6a059 cp_build_binary_op(op_location_t const&, tree_code, tree_node*,
tree_node*, int)
        ../../gcc-13-20220522/gcc/cp/typeck.cc:6260
0xa09a50 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, int)
        ../../gcc-13-20220522/gcc/cp/call.cc:6930
0xc5d87e build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node*, tree_node**, int)
        ../../gcc-13-20220522/gcc/cp/typeck.cc:4563
0xbcfba1 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc-13-20220522/gcc/cp/pt.cc:20347
0xbd4c27 instantiate_non_dependent_expr_internal(tree_node*, int)
        ../../gcc-13-20220522/gcc/cp/pt.cc:6366
0xbd4c27 instantiate_non_dependent_expr_sfinae(tree_node*, int)
        ../../gcc-13-20220522/gcc/cp/pt.cc:6387
0xc2d789 finish_decltype_type(tree_node*, bool, int)
        ../../gcc-13-20220522/gcc/cp/semantics.cc:11297
0xb837d1 cp_parser_decltype
        ../../gcc-13-20220522/gcc/cp/parser.cc:16578
0xb9cd49 cp_parser_simple_type_specifier
        ../../gcc-13-20220522/gcc/cp/parser.cc:19693
0xb78a07 cp_parser_type_specifier
        ../../gcc-13-20220522/gcc/cp/parser.cc:19470
0xb79a21 cp_parser_decl_specifier_seq
        ../../gcc-13-20220522/gcc/cp/parser.cc:15940
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.

$ g++ -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-debug-13.0.0/bin/g++
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-debug-13.0.0/libexec/gcc/x86_64-unknown-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20220522 (experimental) (GCC)


More information about the Gcc-bugs mailing list