3 ms·
Strictly speaking, this wouldn't be C any more. But it would be a bit more memory-safe.
by classified 3y ago
Strictly speaking, this wouldn't be C any more. But it would be a bit more memory-safe.
- znpy 3y agoC compilers have been doing stuff like that for decades… trivial example: many compilers will insert an implicit return statement if you don’t do that. Without this code execution would just continue to whatever function is in memory, if there’s one. And yet… it’s still considered c language.
- andreareina 3y agoI think they meant more the new syntax.
- carbotaniuman 3y agoImplementation extensions have been around for decades. This seems as C as it can get! Also, the compiler has license to replace UB with anything, might as well be helpful.
- SAI_Peregrinus 3y agoIt's still conforming C. It's not strictly conforming C, but no compiler extensions are. I'm not aware of any compiler that fully enforces strictly conforming C. It may not even be possible, since a strictly conforming program "shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior"[1], which would require the compiler to reject any program that produces such output even though some cases can only be detected at runtime. And since strictly conforming programs can only use features of the language and standard library defined in the C standard, the compiler can't even insert runtime checks to exit the program if such behavior is encountered (since that would be a language extension). [1] C17 standard 4.5
- jjnoakes 3y agoExisting compilers that know nothing of the new annotations can still compile the code (without the checks obviously) using the macro definitions provided in the article.
- cryptonector 3y agoIf adopted by the C committees, would this then no longer "[not] be C any more"?
- TazeTSchnitzel 3y agoOut-of-bounds accesses are undefined behaviour. A compiler is free, within the bounds of the standard, to do whatever it wants for them, including doing dynamic checks.