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

--- Comment #7 from Martin Uecker <muecker at gwdg dot de> ---

An attribute is certainly simpler and should be easy to add.

I proposed similar extension for C23 and there was some interest,
but I did not have time to follow up.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2660.pdf


Sizeof is not a constant expression in ISO C for a VLA and it is not a constant
expression if the struct contains a VLA  (GNU extension).  So this is already
the case and nothing would need to change.  It would also potentially avoid
mistakes when computing the size of such a struct. But the rules for
initialization are not so clear.

I do not think it is a good idea to differentiate between file scope structs
and others. This would be confusing. 

Considering that the GNU extensions is rarely used, one could consider
redefining the meaning of

int n = 1;
struct {
  int n;
  char buf[n];
};

so that the 'n' refers to the member. Or we add a new syntax similar to
designators (which intuitively makes sense to me).

Reply via email to