This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/86943] [7/8/9 Regression] Wrong code when converting stateless generic lambda to function pointer
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Dec 2018 17:09:17 +0000
- Subject: [Bug c++/86943] [7/8/9 Regression] Wrong code when converting stateless generic lambda to function pointer
- Auto-submitted: auto-generated
- References: <bug-86943-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86943
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'll just include the testcase for the testsuite from the above patch:
// PR c++/86943
// { dg-do run { target c++14 } }
int c[3];
struct S
{
S () : s (1234) { c[0]++; }
S (const S &) { __builtin_abort (); }
S (S &&x) noexcept { if (x.s != 1234) __builtin_abort (); s = 1234; x.s =
2345; c[1]++; }
~S () { if (s != 1234 && s != 2345) __builtin_abort (); c[2]++; }
int s;
};
using F = void (*) (S);
F
foo ()
{
return [] (auto val) { if (val.s != 1234) __builtin_abort (); };
}
int
main ()
{
{
volatile F f = foo ();
f ({});
}
if (c[0] + c[1] != c[2])
__builtin_abort ();
}