[Bug c++/104765] New: Expression statement with a return in a lambda-parameter-default causes segfault when called in a different function

2022-03-02 Thread erich.keane at intel dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104765

Bug ID: 104765
   Summary: Expression statement with a return in a
lambda-parameter-default causes segfault when called
in a different function
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: erich.keane at intel dot com
  Target Milestone: ---

See this example:


template
void call_lambda(T&& L) {
L();
}

int g() {  
  auto x = [](char c = ({return 5;'c';})){};

  call_lambda(x);
  return 0;
}

int main() {
  return g();
}

:https://godbolt.org/z/T1cs766cM

Output is:
during RTL pass: expand
: In function 'void call_lambda(T&&) [with T = g()::&]':
:3:6: internal compiler error: Segmentation fault
3 | void call_lambda(T&& L) {
  |  ^~~
0x217ccb9 internal_error(char const*, ...)
???:0
0x1288575 coalesce_ssa_name(_var_map*)
???:0
0x120fadb rewrite_out_of_ssa(ssaexpand*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1




This gets somewhat more interesting when the return value of 'call_lambda' is
non-int:

https://godbolt.org/z/rE619qbz3

: In function 'long int call_lambda(T&&)':
:5:1: warning: no return statement in function returning non-void
[-Wreturn-type]
5 | }
  | ^
: In function 'long int call_lambda(T&&) [with T =
g()::&]':
:3:6: error: invalid conversion in return statement
3 | long call_lambda(T&& L) {
  |  ^~~
long int

int

return D.2194;
:3:6: internal compiler error: 'verify_gimple' failed
0x217ccb9 internal_error(char const*, ...)
???:0
0x1183efd verify_gimple_in_seq(gimple*)
???:0
0xdf13b1 gimplify_body(tree_node*, bool)
???:0
0xdf1677 gimplify_function_tree(tree_node*)
???:0
0xbf78f7 cgraph_node::analyze()
???:0
0xbfbe0d symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1



IMO, expression-statements in default-lambda parameters are... awkward and
perhaps worth just prohibiting.

[Bug c++/94960] extern template prevents inlining of standard library objects

2022-02-17 Thread erich.keane at intel dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94960

--- Comment #9 from Erich Keane  ---
> But in C++20 every function is 'constexpr' now, so every function is inline
> anyway, right? Even the large functions that aren't good candidates for
> inlining (see also PR 93008). So The 'inline' keyword has lost all meaning
> in  now.

Do you mean 'every function in std::string'?  If so, you'd know better than I.
In a general case, every function is NOT 'constexpr', and that didn't pass EWG.