> On Jul 31, 2018, at 1:08 PM, Timothe Litt <l...@ieee.org> wrote: > > On 31-Jul-18 12:41, Paul Koning wrote: >> >> >> One thing that happens with newer compilers is that they take more advantage >> of opportunities offered by the letter of the standard. If you do something >> that is "undefined", the compiler can do with that whatever it wants to. If >> you have code that appears to allow something undefined under certain >> conditions, the compiler is free to assume that the undefined thing cannot >> happen and therefore that scenario doesn't occur. >> >> ... > > You probably mean > https://people.csail.mit.edu/nickolai/papers/wang-stack-tocs.pdf
No, but thanks for that pointer. The paper I was thinking about is listed in the references: Xi Wang, Haogang Chen, Alvin Cheung, Zhihao Jia, Nickolai Zeldovich, and M. Frans Kaashoek. 2012a. Undefined behavior: What happened to my code? In Proceedings of the 3rd Asia-Pacific Workshop on Systems. > For more reading, see, e.g. http://port70.net/~nsz/c/c99/n1256.html#J.2, > https://cacm.acm.org/magazines/2016/3/198849-a-differential-approach-to-undefined-behavior-detection/fulltext, > https://blog.regehr.org/archives/1520, > https://runtimeverification.com/blog/undefined-behavior-review-and-rv-match/ > > The last is a competitive analysis - but quite informative nonetheless. > > In additions to -Wall, I also used to compile SimH with -pedantic and > -Werror. And usually one of the -std flags. Hm, -pedantic is specificially intended to be "the warnings that aren't really useful for general use and real code". > Another big potential gotcha in SimH is the heavy use of casts, and type > aliasing rules (the latter especially problematic in subroutine calls). Yes, aliasing is a big problem area. If you get any warnings about strict aliasing, fixing them (via unions) is a good idea. Alternatively, fno-strict-aliasing can be used but that comes with a performance cost and is not the best answer. paul _______________________________________________ Simh mailing list Simh@trailing-edge.com http://mailman.trailing-edge.com/mailman/listinfo/simh