This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/86943] [7/8/9 Regression] Wrong code when converting stateless generic lambda to function pointer


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 ();
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]