[Bug c++/94068] New: Internal compiler error when trying to resolve function overload

2020-03-06 Thread plexando at protonmail dot com
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 

enum class Enum { A };

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

template
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.

[Bug libstdc++/93795] New: Out-of-line definition of class member template with 'requires std::invocable' constraint fails to compile

2020-02-17 Thread plexando at protonmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93795

Bug ID: 93795
   Summary: Out-of-line definition of class member template with
'requires std::invocable' constraint fails to
compile
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: plexando at protonmail dot com
  Target Milestone: ---

A class member template having a constraint with a 'requires std::invocable'
clause fails to compile if defined out-of-line.

For instance, the program

#include 
#include 

struct S {
template requires std::invocable
void f(T&& t);
};

template requires std::invocable
void S::f(T&& t) { t(); }

int main() {
S{}.f([] { std::cerr << -1 << std::endl; });
}

does not compile with GCC 10.0.1 20200214 (experimental) on x86_64 GNU/Linux
(It does compile however if the member template is defined in-line).

Compiler output (using g++ prog.cc -Wall -std=gnu++2a) is:

prog.cc:13:1: error: no declaration matches 'void S::f(T&&)'
   13 | S::f(
  | ^
prog.cc:7:10: note: candidate is: 'template  requires  invocable
void S::f(T&&)'
7 | void f(T&& t);
  |  ^
prog.cc:4:8: note: 'struct S' defined here
4 | struct S {
  |^
prog.cc:7:10: error: 'void S::f(T&&) [with T = main()::]', declared
using local type 'main()::', is used but never defined [-fpermissive]
7 | void f(T&& t);
  |  ^
prog.cc:7:10: warning: 'void S::f(T&&) [with T = main()::]' used but
never defined

Configure options were ./configure --prefix=/usr/local/gcc-10-20200209.