https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94537
Bug ID: 94537
Summary: Possibly wrong code with mandatory copy elision and
'this' pointer arithmetic inside an NSDMI
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ppalka at gcc dot gnu.org
Target Milestone: ---
$ cat testcase.C
struct A { A *p = this-1; int n = p->n; };
constexpr A
foo()
{
return {};
}
A a[2] = { {nullptr, 5}, foo() };
int
main()
{
if (a[1].n != 5)
__builtin_abort ();
}
$ g++ testcase.C
$ ./a.out
zsh: abort ./a.out