3 ms·
> the C23 auto proposal which contains a special exception for Clang's behaviour which clashes with GCC's behaviour Can you explain what that is? There’s supre
by mananaysiempre 3y ago
> the C23 auto proposal which contains a special exception for Clang's behaviour which clashes with GCC's behaviour
Can you explain what that is? There’s supreme awkwardness around allowing `auto int i;` at block scope to work as before (with `auto` being ignored), but I’ve stared at that proposal a fair bit and haven’t noticed such an exception there.
- flohofwoe 3y agoThe details are buried in the proposal and make for an interesting read, but the gist is that Clang's C frontend has a "C++ style" auto keyword where a pointer can be declared both with "auto" and "auto*" (and this was already baked into the existing __auto_type extension before C23 came along). For instance this is valid Clang C23 code (and entirely C23 standard-compliant): int i = 0; auto p0 = &i; auto* p1 = &i; ...both p0 and p1 have the same type of int*. In GCC this code doesn't compile because GCC already had a simpler "C style" __auto_type extension which doesn't allow the form "auto*", but this behaviour is also entirely valid C23 ¯\_(ツ)_/¯. (personally I prefer GCC's version as it makes more sense for C) This will cause some head-scratching when code that builds on Clang doesn't build on GCC, especially since Clang usually tries to emulate GCC behaviour. But OTH I think/hope that C's auto will only be used when absolutely necessary in "type-generic" macros, and no "almost always auto" nonsense which was fashionable in the C++ world for a while.