On Wed, 2013-11-13 at 11:39 +0100, Richard Biener wrote: > On Wed, Nov 13, 2013 at 1:39 AM, Joseph S. Myers > <jos...@codesourcery.com> wrote: > > <stdatomic.h> contains what C11 describes as "generic functions". > > Although DR#419 makes clear that users cannot #undef these macros (or > > otherwise suppress use of a macro definition) and expect to find an > > underlying function, they still need to behave like functions as > > regards evaluating their arguments exactly once (see C11 7.1.4). > > > > I noted when adding <stdatomic.h> to mainline that some of the macro > > definitions there failed that requirement in the case where the > > pointer argument had variably modified type, because then typeof > > evaluates its argument and so that argument would be evaluated twice. > > Avoiding such double evaluation requires defining the type of a > > temporary variable, and initializing it with the pointer argument, > > with a single evaluation. To achieve this, this patch adds a new GNU > > C extension __auto_type, essentially a restricted version of C++11 > > auto, and uses it in <stdatomic.h>. > > I suppose you didn't use '__auto' because that's much more likely > used elsewhere than '__auto_type'?
I have no idea, but does anyone knows if other free compilers (notably Clang/LLVM) are adding a similar feature? If they do, perhaps (if it is not too painful) we should use the same keyword (i.e. __auto_type) and a similar semantics. And I also like that feature, but it should be documented outside of the support of <stdatomic.h> since it is genuinely useful by itself (e.g. as an alternative to typeof). Regards. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} ***