C nowadays is an insanely hostile programming environment. A C compiler relentlessly scours your program for any place where may have violated C’s almost incomprehensible rules, so that it can compile your apparently-correct program into a buggy executable.
Yesterday I had a C compiler optimise my main() into literally zero instructions. Not even a return instruction. It silently output an object file which would cause execution to fall off the bottom of main() into whatever the linker had happened to put next in the image!
The sin: a float-to-uint32 conversion with input value exactly 232, i.e. only just an overflow.
This was grounds to emit an executable that could not possibly be what anybody ever wanted. But not grounds to print so much as a compiler warning, even at -Wall!
(no subject)
Date: 2025-03-28 01:17 pm (UTC)Yesterday I had a C compiler optimise my
main()
into literally zero instructions. Not even a return instruction. It silently output an object file which would cause execution to fall off the bottom ofmain()
into whatever the linker had happened to put next in the image!The sin: a float-to-uint32 conversion with input value exactly 232, i.e. only just an overflow.
This was grounds to emit an executable that could not possibly be what anybody ever wanted. But not grounds to print so much as a compiler warning, even at
-Wall
!