3 ms·
This is a meaningless article. A compiler that chooses to perform an optimization (transformation) which does not preserve the defined semantics of the language
by riscy 11y ago
This is a meaningless article. A compiler that chooses to perform an optimization (transformation) which does not preserve the defined semantics of the language has a bug, by the definition of what a compiler is. What is the argument?
- jfoutz 11y agosomething like -Ofast is well defined. the thing is, it defines another language closely related to the source language but with some extra constraints. So you have C, and also C'. It may be the case that all the C in your program happens to be valid C', but probably not. If you're not acutely aware of the rules of C', you won't get what you want. And, some poor hapless C programmer may find themselves working on a C' project and not know it, or the expert is suddenly a beginner again, because they need to learn the extra rules of the game. It's all well defined. it's a social problem. it's something to be aware of.
- deleted 11y ago[deleted]
- riscy 11y ago> If you're not acutely aware of the rules of C', you won't get what you want. The same can be said of any language that lacks a rigorous definition; misusing -Ofast is just an example of one. Even then, the definition can be too large or tricky for anybody to truly understand, but that's a bit of a grey area... at some point you have to draw the line and say the programmer made a mistake. The only sensible thing to do is draw the line at the definition of the language, otherwise there is chaos.