3 ms·
Does GCC include any flags to prevent this sort of detrimental optimization?
by jstanek 12y ago
Does GCC include any flags to prevent this sort of detrimental optimization?
- prof_hobart 12y agoThere's a bunch listed (https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Optimize-Options.html https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Optimize-Options....), including -O0 // Do Not Optimise This sounds like it should do the trick (but I've not done C coding for quite some time, so I don't know if there's a nuance as to why it wouldn't), but would also presumably kill any other optimisation. A better option may be to combine that with pragmas (https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-...) to switch optimisation levels within the code. Anyone who's played with GCC recently know whether this would work or not?
- zokier 12y agoYou mean something like friendly C: http://blog.regehr.org/archives/1180 http://blog.regehr.org/archives/1180 (discussed on HN 8 days ago: https://news.ycombinator.com/item?id=8233484 https://news.ycombinator.com/item?id=8233484)