[Bug middle-end/114913] "verify_gimple failed" due to addition of two constexpr strings

2024-05-01 Thread jorg.brown at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114913

--- Comment #4 from Jorg Brown  ---
Oddly, if I move the reference to HelloWorld into a separate routine, it works
(you can comment out a() and ba() returns what it should, on gcc 15.0)

struct strt {
  const char *ptr = 
  char data = '\0';

  constexpr strt() {}
  constexpr strt(const strt &__str) {}
};
constexpr strt f() { return {}; }
constexpr strt HelloWorld = f();

// This works fine...
const strt () { return HelloWorld; }
const char *ba() { return b().ptr; }

// This causes the verify_gimple failure, on gcc 15
const char *a() { return HelloWorld.ptr; }

= - = - = - = - = - = - =

Also odd is that the above code (including a()) works fine on gcc 10.1 through
13.2.  As seen https://godbolt.org/z/z3qnosG37

[Bug c++/114913] New: "verify_gimple failed" due to addition of two constexpr strings

2024-05-01 Thread jorg.brown at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114913

Bug ID: 114913
   Summary: "verify_gimple failed" due to addition of two
constexpr strings
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jorg.brown at gmail dot com
  Target Milestone: ---

Source:

#include 

constexpr std::string Hello = "Hello, ", World = "World.";
constexpr std::string HelloWorld = Hello + World;

int main() { printf("%s\n", HelloWorld.c_str()); }

= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =

Version:

g++
(Compiler-Explorer-Build-gcc-610415bb7ddc5626ec301ca20833e78696978601-binutils-2.40)
15.0.0 20240501 (experimental)
Copyright (C) 2024 Free Software Foundation, Inc.

ASM generation compiler returned: 0
g++
(Compiler-Explorer-Build-gcc-610415bb7ddc5626ec301ca20833e78696978601-binutils-2.40)
15.0.0 20240501 (experimental)
Copyright (C) 2024 Free Software Foundation, Inc.

= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =

As seen at https://godbolt.org/z/hd1TbM61Y , I got:

: In function 'int main()':
:8:50: error: constant not recomputed when 'ADDR_EXPR' changed
8 | int main() { printf("%s\n", HelloWorld.c_str()); }
  |  ^
_3 = _M_local_buf;
during GIMPLE pass: einline
:8:50: internal compiler error: verify_gimple failed
0x267adac internal_error(char const*, ...)
???:0
0x13e317e verify_gimple_in_cfg(function*, bool, bool)
???: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

= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =

I don't have access to the gcc executable causing this problem, and
-freport-bug doesn't work from godbolt, so I can't give you the preprocessed
input.

[Bug c++/101430] New: Passing a lambda as a template argument causes internal compiler error

2021-07-12 Thread jorg.brown at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101430

Bug ID: 101430
   Summary: Passing a lambda as a template argument causes
internal compiler error
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jorg.brown at gmail dot com
  Target Milestone: ---

This code causes gcc 11.1.0 to ICE:

extern "C" {
  int printf(const char *, ...);
}

void g(int n) { printf("%d\n", n); }

template void f(decltype(Lambda) x = {}) {
x();
}

int main() {
constexpr auto a = []{ g(3); };
//f();

f<[]{g(2);}>();

f();
}

Output when compiled:


x86-64 gcc 11.1 (Editor #1, Compiler #1) C++
x86-64 gcc 11.1
-std=c++20 
123


# For more information see the output window
x86-64 gcc 11.1 - cached
Output of x86-64 gcc 11.1 (Compiler #1)
: In substitution of 'template void f(decltype (Lambda))
[with auto Lambda = ]':
:17:6:   required from here
:7:33: internal compiler error: in convert_nontype_argument, at
cp/pt.c:7652
7 | template void f(decltype(Lambda) x = {}) {
  | ^
0x1780bf9 internal_error(char const*, ...)
???:0
0x677e40 fancy_abort(char const*, int, char const*)
???:0
0x7f3b4b fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x68eda2 build_new_function_call(tree_node*, vec**, int)
???:0
0x8070f0 finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x7c0cab c_parse_file()
???:0
0x892aa2 c_common_parse_file()
???:0

Compiler Explorer link: https://godbolt.org/z/Evcd7oaz5


Interestingly, if I comment out the definition of `a`, it compiles and runs
properly.

And if I comment out either of the last two calls to f(), it compiles and runs
properly.  Whether or not f(); is commented out.