<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div> can still detect them.</div><div><br></div><div>Following, I have the following questions/suggestions:</div><div>- Is it known that Clang performs optimizations that hide program bugs, even when compiling with -O0?</div></div></blockquote><div>Some, yes, some no.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>- Are there command line options to specify that no optimizations should be performed? </div></div></blockquote><div><br></div><div>It is not possible to compile all code correctly without optimization, interestingly enough.  It would be nice though.</div><div>In fact, i expect things like C++ constexpr make this significantly worse.</div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Until recently, I thought that -O0 had this effect.</div><div>- In each case, I would propose to not perform optimizations at -O0 to allow dynamic bug finding tools to find such bugs, or at least offer a flag to turn off optimizations altogether.</div><div><br></div></div></blockquote><div>Again, this is impossible :)</div><div>For example, there are high profile things that depend on always_inline functions not existing after inlining.</div><div>This inlining can definitely hide bugs (smashing call stacks, etc).</div><div>But we have to do it anyway.</div><div><br></div><div>So as a general statement, your proposal will not work.</div><div>If you revised it to "the minimum set of optimizations necessary for correctness", it would be doable, but that set already conflicts in a number of ways with "dynamic bug finding tools" :(</div><div><br></div></div></div></div>