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++/81073] [5/6/7/8 Regression] link failure as C++ misses to instanciate some objects


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

--- Comment #10 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #9)
> Created attachment 41711 [details]
> patch to error on progmem with dynamic init
> 
> Does this do what you had in mind?

Some situations are diagnosed, but already something like in this PR passes
your test und dynamically initializes __c in .rodata:

#define PROGMEM __attribute__((__progmem__))

// A string in flash
#define PSTR(str)                               \
  (__extension__({                              \
      static const char __c[]  = (str);         \
      &__c[0];                                  \
    }))

typedef struct { char id; const char *labl; } menu_t;

const menu_t* setup_Flash (void)
{
  static const menu_t menu PROGMEM = { 123, PSTR ("in Flash") };
  return &menu;
}

int main(){}

So either this should be diagnosed or deflate similar to

const menu_t* setup_RAM (void)
{
  static const menu_t menu PROGMEM = { 123, "in RAM" };
  return &menu;
}

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