r/programming • • Feb 01 '20

Emulator bug? No, LLVM bug

https://cookieplmonster.github.io/2020/02/01/emulator-bug-llvm-bug/
282 Upvotes

87 comments sorted by

View all comments

Show parent comments

6

u/flatfinger Feb 02 '20

"I don't seem to know the rules it's building off of to that to decide what it does".

For years before the Standard was ratified, and continuing ever since, there have been many situations which different implementations would process constructs in the same useful fashion, but do so for different reasons. Rather than trying to document detailed rules which would require some implementation to expend lots of effort handling useless corner changes, the Standard sought instead to describe a few cases where implementations should be expected to behave consistently, and figured that implementations meeting those would naturally as a consequence also handle other cases their customers would require.

Unfortunately, gcc and clang both evolved abstraction models which are grossly incompatible with a lot of legacy code and can't really handle all of the corner cases in the Standard. There are some cases in the Standard that would needlessly handle optimization, but there are others such as the Common Initial Sequence guarantees which were included to facilitate constructs beyond those mandated by the Standard. From what I can tell, the maintainers of these compilers view places where the Standard doesn't fit their abstraction model as defects in the Standard; I'm not sure whether one can really describe as a "bug" a situation where clang and gcc both behave in the same nonsensical fashion.

1

u/fresh_account2222 Feb 02 '20

^ Best comment I've read in a while.