logoalt Hacker News

raverbashingyesterday at 1:12 PM3 repliesview on HN

Nope it is the C committee

> Once you accept that optimizing compilers do, well, optimizations

Why in tarnation it is optimizing out a write to a pointer out before a function that takes said pointer? Imagine it is any other function besides free, see how ridiculous that sounds?


Replies

rectangyesterday at 6:42 PM

It's been many years since C compilers started making pathological-but-technically-justifiable optimizations that work against the programmer. The problem is the vast sea of "undefined behavior" — if you are not a fully qualified language lawyer versed in every nook and cranny of the C standard, prepare to be surprised.

Many of us who don't like working under such conditions have just moved on to other languages.

show 1 reply
ueckeryesterday at 1:22 PM

Because it is a dead store. Removing dead stores does not sound ridiculous to me and neither is it to anybody using an optimizing compiler in the last decades.

shaknayesterday at 1:38 PM

Tree shaking is pretty standard. Optimising out the write sounds fine to me - with the exception of a volatile pointer. That, there, is a mistake.

show 1 reply