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

            Bug ID: 96359
           Summary: ICE in cxx_eval_logical_expression, at
                    cp/constexpr.c:3875
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: error-recovery, 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: ---

Hi, all.

This invlaid code makes GCC ICE. What shocked me is that when I change the
value of b (for example, let b=1), GCC performs well in error-recovery.

Input:
//small.cc
short a;
const char b = 5;
explicit void c (auto, int = b or a, enum {});

Command:
g++ -w small.cc

Output:
small.cc:4:38: error: types may not be defined in parameter types
    4 | explicit void c (auto, int = b or a, enum {});
      |                                      ^~~~
small.cc:4:45: internal compiler error: in cxx_eval_logical_expression, at
cp/constexpr.c:3875
    4 | explicit void c (auto, int = b or a, enum {});
      |                                             ^
0x61b51e cxx_eval_logical_expression
        ../../gcc/cp/constexpr.c:3875
0x8d5fdf cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6133
0x8d938f cxx_eval_outermost_constant_expr
        ../../gcc/cp/constexpr.c:6756
0x8dd7ab maybe_constant_value(tree_node*, tree_node*, bool)
        ../../gcc/cp/constexpr.c:7029
0x907264 cp_fully_fold(tree_node*)
        ../../gcc/cp/cp-gimplify.c:2464
0x90e7cf cp_convert_and_check(tree_node*, tree_node*, int)
        ../../gcc/cp/cvt.c:661
0x89a679 convert_like_internal
        ../../gcc/cp/call.c:7846
0x89bf59 convert_like
        ../../gcc/cp/call.c:7892
0x89bf59 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
        ../../gcc/cp/call.c:11907
0x921e0f check_default_argument(tree_node*, tree_node*, int)
        ../../gcc/cp/decl.c:13924
0x92246f grokparms(tree_node*, tree_node**)
        ../../gcc/cp/decl.c:14112
0x933889 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
        ../../gcc/cp/decl.c:12393
0x93ed08 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ../../gcc/cp/decl.c:5232
0x9ed46d cp_parser_init_declarator
        ../../gcc/cp/parser.c:20846
0x9cdacc cp_parser_simple_declaration
        ../../gcc/cp/parser.c:13799
0x9f8d2e cp_parser_declaration
        ../../gcc/cp/parser.c:13498
0x9f941b cp_parser_translation_unit
        ../../gcc/cp/parser.c:4781
0x9f941b c_parse_file()
        ../../gcc/cp/parser.c:44069
0xb13e2d c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1188
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.

My gcc version is:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/tuhaoxin/compilers/gcc-0726/build/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure CC=gcc-10 CXX=g++-10
--prefix=/home/hatuhaoxin/compilers/gcc-0726/build/ --enable-languages=c,c++
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200726 (experimental) (GCC) 

Thanks,
Haoxin

Reply via email to