On Fri, Sep 6, 2024 at 11:16 PM Martin Uecker <ma.uec...@gmail.com> wrote: > > Am Samstag, dem 07.09.2024 um 00:12 +0000 schrieb Qing Zhao: > > Now, if > > > > 1. __builtin_get_counted_by should return a LVALUE instead of a pointer > > (required by CLANG’s design) > > And > > 2. It’s better not to change the behavior of __builtin_choose_expr. > > > > Then the solution left is: > > > > __builtin_get_counted_by (p->FAM) returns a LVALUE as p->COUNT if p->FAM > > has a counted_by attribute, if p->FAM does not have a counted_by attribute, > > silently do nothing. (Or just issue warning if Linux is OKEY with such > > waning). > > What does silently do nothing mean? > > /* do nothing */ = counter; > > will still fail to compile. So I guess you have something > else in mind? > > > The new _Generic selection also works if you return a > lvalue of type void: > > struct foo x; > _Generic(typeof(__counted_by(&x)), void: (int){ 0 }, > default: __counted_by(&x)) = 10; > > https://godbolt.org/z/41E3oj84o > > So why not do this then? > I'm for any solution that a.) works with the fewest changes needed to other builtins, and 2.) isn't super convoluted. The '_Generic' looks like a potential compromise.
-bw