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

David Crocker <dcrocker at eschertech dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcrocker at eschertech dot com

--- Comment #2 from David Crocker <dcrocker at eschertech dot com> ---
I have found another bug involving a const pointer to a lambda function, that
goes away if I use -std=gnu++17. I am constructing a const table of structs
that has a field of function pointer type, and I need it to go into .rodata
because of limited RAM on an embedded platform. I would like to use lambda
functions in the table definition, for example:

  const ObjectModelTableEntry RepRap::objectModelTable[] =
  {
    { ..., [] (ObjectModel* self) { return (void
*)&(((RepRap*)self)->GetGCodes()); }, ... }
  };


Using GCC 7.3.1 20180622 with std=gnu++14, the compiler doesn't put this in the
rodata segment. If I change it to:

  static void* func(ObjectModel *self) { return (void
*)&(((RepRap*)self)->GetGCodes()); }

  const ObjectModelTableEntry RepRap::objectModelTable[] =
  {
    { ..., func, ... }
  };

then it does put it in rodata.

Reply via email to