Am Dienstag, dem 25.03.2025 um 19:09 -0700 schrieb Bill Wendling:
> On Tue, Mar 18, 2025 at 3:04 PM Martin Uecker <uec...@tugraz.at> wrote:
> > 

> 
> It seems clear that using "__self" is most likely going to be part of
> any solution we come up with. What we need to avoid is feature skew
> between GCC and Clang. It'll revert projects back into the "compiler
> war" days, which isn't beneficial to anyone. Is there a compromise
> that's acceptable for both GCC and Clang beyond adding "__self", but
> not requiring it?

Having the syntax but not requiring it does not solve the problem,
because it would still require compilers to implement late parsing
(a problem for many C compilers).

If we require __self__ now, this would allow us to move on while
leaving the door open to finding consensus later, e.g. after WG14
has considered it in the next meeting.  

Martin



> 
> -bw
> 
> > >  That said this is just my own impression and whether we can make the 
> > > usable model this way may need more study.
> > > 
> > > At least now I understand what is your vision. Thanks.
> > > 
> > > > 
> > > > For GNU C (but not ISO C) there could be size expression in
> > > > the declaration referring to automatic variables.
> > > > 
> > > > int foo()
> > > > {
> > > >  int n = 1;
> > > >  struct {
> > > >   char buf[n]; // evaluated when the declaration is reached
> > > >  } x;
> > > > };
> > > > 
> > > > This is something which can not currently happen for ISO C where
> > > > this can only refer to named constants and where the size is
> > > > evaluated at compile time.
> > > > 
> > > > int foo()
> > > > {
> > > >  enum { N = 1 };
> > > >  struct {
> > > >    char buf[N];
> > > >  } x;
> > > > }
> > > > 
> > > > Still, I think this is another reason why it would be much
> > > > better to have new syntax for this.  We also need to restrict
> > > > the size expressions in all three scenarios in different ways.
> > > > 
> > > > int foo()
> > > > {
> > > >  int n = 1;
> > > >  struct {
> > > > 
> > > >    int m;
> > > >    char buf1[n];    // evaluated when the declaration is reached
> > > >    char buf2[.m];   // evaluated on access to buf2, restricted syntax
> > > >  } x { .m = 10 };
> > > > }
> > > > 
> > > > 
> > > > Martin
> > > 
> > > Yeoul
> > > 
> > 

Reply via email to