4 ms·
Because it changes the meaning of existing code. That's a big no-no.
by quelsolaar 3y ago
Because it changes the meaning of existing code. That's a big no-no.
- JonChesterfield 3y agoMaybe people could grep for "auto" in their codebase, see it's not there, and then change to C23? Though realistically if this looks like a problem it's a trivial compiler diagnostic. "Would this thing have a different type in C23 to earlier? Emit a warning, promotable to error". The whole changes meaning panic is rather overdone and mostly acts to stop C improving over time.
- actionfromafar 3y agoChesters' (green) field, where Chesterton's fence is. :)
- quelsolaar 3y agoYou cant make a compiler diagnostic, because it was valid before and after C23, the code just means different things. In fact just using auto without a type was bad practice in earlier versions, now it can be considered a feature, so its less likely to give you a warning now than in the past.
- JonChesterfield 3y agoThe obvious diagnostic would be "if auto and < C23, emit warning". That can definitely be implemented. Choosing the name would take longer than writing the code. Lots of stuff is valid and gets warnings on request, like `if (a = b)`, or anything where people get precedence or aliasing rules often enough that someone bothered to patch the compiler.
- quelsolaar 3y agoThat is if you know about this issue. Very few people do. At some point C23 may become a default version of C in some compilers and someone who has been building code without specifying what version of C they use, will silently get a bug. That is the problem. There is no way for a C compiler to look at the code and determine what version it was written for.
- uecker 3y agoImplicit int was removed in C99. Since then most compilers warn about this in default compilation mode.
- jcelerier 3y agoCompilers already have diagnostic for these exact things ("because it was valid before and after C23, the code just means different things"), e.g. all the -wc99-compat warnings