3 ms·
unless required to do so by the spec Which IMHO is an absolutely stupid point of view, because compilers don't exist in a void. As the old saying goes, "what's
by userbinator 7y ago
unless required to do so by the spec
Which IMHO is an absolutely stupid point of view, because compilers don't exist in a void. As the old saying goes, "what's right isn't always legal, and what's legal isn't always right", and behaving to the letter of the law is not the same as behaving to the spirit of the law.
Thus I think it is absolutely a bug. The standard even says undefined behaviour may result in something like "behaving in a manner characteristic of the environment", which is absolutely what programmers expect from the language.
I also suspect the fact that GCC has become a de-facto monopoly (duopoly if you count Clang/LLVM) among C compilers for Linux platforms makes them more likely to dismiss such complaints.
My experience agrees with yours that ICC and MSVC are nowhere near as aggressive and hostile with UB, yet still generate very good code.
- MaulingMonkey 7y ago> Thus I think it is absolutely a bug. While I agree with your rationale, I disagree with it's application in this case. Changing this compiler behavior won't get rid of alignment-related crashes - it'll just make them harder for me to reproduce / debug because I'll have to get coredumps and symbols off of my ARM hardware instead. > [...] MSVC [...] Has it's own history of alignment issues as well FWIW, although I'm happy to see that v19 seems to error out on __declspec(align(...))ments it won't guarantee for parameters - whereas that used to be a mere warning. A warning that was missing and wouldn't trigger in at least one MSVC version, which caused it's share of debugging sessions for me: https://clang.godbolt.org/z/hykGEm https://clang.godbolt.org/z/hykGEm
- __s 7y agoGiven that it's gcc is generating instructions which require alignment "behaving in a manner characteristic of the environment" is one way of describing this situation
- userbinator 7y agoThen perhaps Intel is ultimately to blame for this mess, since requiring alignment is completely at odds with how x86 normally behaves, and as shown in the article, there's a version of the instruction not requiring alignment and not really slower at all.