Evil proposed compiler optimization: in __attribute(__pure__)__ functions, optimize malloc(n) to 0.
This optimization is not based on UB. It's based on you having told the compiler that the result must be the same regardless of whether malloc succeeds or fails (as a pure function of the argument values).
-
-
I can't speak authoritatively on __attr__((const)), but all I think it says is that the result is the same whenever it gets called, only args are looked at, and no other observable effects. The compiler would need to prove "malloc fails" is reachable to make that inference.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.