https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
--- Comment #35 from qinzhao at gcc dot gnu.org --- (In reply to Martin Uecker from comment #34) > Created attachment 54787 [details] > patch for C FE to add size expressions to VM types in structs thanks a lot for the patch. could you please provide a small testing case that works with this patch that I can take a further look? I tried very simple one, didn't compile: struct P { int k; int x[.k]; }; void foo (int n) { struct P p; p.k = n; return; } > > It works with UBSan, but it isn't clear how this could pass the > information to the object size pass. This also does not work for > parameters: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109334 >From your change, I can see that you put the ".k" info to the index of the array type for x[.k], so I guess that other passes can refer the index of the array type to get the max size of this array. > > So it seems for an attribute it might make sense to implement > it differently. implement should be different. but the functionality of the user interface is better to be kept consistent between attribute and language extension. i.e in addition to the basic: struct P { int k; int x[.k]; }; will you support expressions: struct P { int k; int x[.k * 4]; } ? or other more complicated syntax?