5 ms·
You 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
by quelsolaar 3y ago
You 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