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

            Bug ID: 94068
           Summary: Internal compiler error when trying to resolve
                    function overload
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: plexando at protonmail dot com
  Target Milestone: ---

The following program crashes GCC 20200304 (experimental):

#include <string>

enum class Enum { A };

Enum f(const char&) { return Enum::A; }
Enum f(const std::string& s) { return f(s[0]); }

template<typename ...ArgTs>
void ExtractFile(const std::string& s) { const auto e { f(s) }; } // const auto
e = f(s) works;

int main() {}

Error message is:

prog.cc: In function 'void ExtractFile(const string&)':
prog.cc:9:62: internal compiler error: unexpected expression 'f' of kind
overload
    9 | void ExtractFile(const std::string& s) { const auto e { f(s) }; } //
const auto e = f(s) works
      |                                                              ^
0x632228 cxx_eval_constant_expression
        ../../source/gcc/cp/constexpr.c:6208
0x62c57d cxx_eval_call_expression
        ../../source/gcc/cp/constexpr.c:2055
0x62f61c cxx_eval_constant_expression
        ../../source/gcc/cp/constexpr.c:5397
0x632610 cxx_eval_outermost_constant_expr
        ../../source/gcc/cp/constexpr.c:6409
0x635915 maybe_constant_value(tree_node*, tree_node*, bool, bool)
        ../../source/gcc/cp/constexpr.c:6697
0x77e941 check_narrowing(tree_node*, tree_node*, int, bool)
        ../../source/gcc/cp/typeck2.c:984
0x662dd9 reshape_init(tree_node*, tree_node*, int)
        ../../source/gcc/cp/decl.c:6503
0x664f5a check_initializer
        ../../source/gcc/cp/decl.c:6702
0x678ff8 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../source/gcc/cp/decl.c:7618
0x6fad51 cp_parser_init_declarator
        ../../source/gcc/cp/parser.c:20839
0x6ddc72 cp_parser_simple_declaration
        ../../source/gcc/cp/parser.c:13689
0x6df82a cp_parser_declaration_statement
        ../../source/gcc/cp/parser.c:13121
0x6e03e5 cp_parser_statement
        ../../source/gcc/cp/parser.c:11434
0x6e11f8 cp_parser_statement_seq_opt
        ../../source/gcc/cp/parser.c:11800
0x6e12b0 cp_parser_compound_statement
        ../../source/gcc/cp/parser.c:11750
0x6f6db0 cp_parser_function_body
        ../../source/gcc/cp/parser.c:22992
0x6f6db0 cp_parser_ctor_initializer_opt_and_function_body
        ../../source/gcc/cp/parser.c:23043
0x6fa39d cp_parser_function_definition_after_declarator
        ../../source/gcc/cp/parser.c:28891
0x6fb2f7 cp_parser_function_definition_from_specifiers_and_declarator
        ../../source/gcc/cp/parser.c:28807
0x6fb2f7 cp_parser_init_declarator
        ../../source/gcc/cp/parser.c:20607
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.

Reply via email to