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++/62052] function parameter has wrong address in lambda converted to pointer-to-function


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62052

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.10.0, 4.7.4, 4.8.2, 4.9.1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Smaller testcase that aborts on error instead of printing addresses to stdout:

extern "C" void __attribute((noreturn)) abort();

struct X;

X const* objects[10];

int find(X const* x)
{
  for (int i=0; i<10; ++i)
    if (objects[i] == x)
      return i;
  abort();
}

struct X
{
  X() {
    objects[ find(nullptr) ] = this;
  }

  X(X const& x) {
    find(&x);
    objects[ find(nullptr) ] = this;
  }

  ~X() {
    objects[ find(this) ] = nullptr;
  }
};

int main()
{
  auto f = [] (X xx) { return xx; };
  X (*ff) (X) = f;
  ff ( X{} );
}


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