3 ms·
What's the warning, "I'd like to optimize this but I can't?" Yes, that's exactly what I had in mind! :)
by iainmerrick 8y ago
What's the warning, "I'd like to optimize this but I can't?"
Yes, that's exactly what I had in mind! :)
- geofft 8y agoMy instinctive response was going to be "That can't work, there are too many of them," but apparently you can do this particular one with -Wnull-dereference (which requires -fdelete-null-pointer-checks enabled to work, but you can just compile twice, once as a throwaway and once for production with -fno-delete-null-pointer-checks, or do the former for non-release builds, or something). More generally, it might be the case that enough of the last several years of unpopular optimizations are controlled by flags that you can compile the code twice, once with the optimization enabled and once without, and warn whenever the optimization changes something. It might even be possible to do this with a shell script that treats the compiler as a black box with -ffunction-sections and uses objdump or something. I do wonder how hard it is to write code that produces the same object code regardless of something more major like -ftrapv, though.