On Tue, 27 Nov 2018 at 22:26, Stephan T. Lavavej
Interestingly [or maybe not so interestingly] MSVC (15.8/7) is the only compiler available there [on godbolt] that does NOT produce more optimal code for
[degski] the
signed integer case (at any optimization level) (STL are you listening).
I am listening, but I am not a compiler backend dev. :-)
I'll give the guys in the garden shed a shout [**hollering**].
I recommend filing a bug about the missed optimization opportunity through the C++ tab of Developer Community at https://developercommunity.visualstudio.com/spaces/62/index.html .
Well, it's UB, so anything can happen, so, is it a bug? It surely misses an opportunity [one compiler just returns 1 on the first function and does absolutely nothing else]. Wrapping signed int's doesn't make much sense [and mixes hardware with software, but hey, that'll go away with C++20]. I'm sympathetic to the effort [of turning it [the UB] into something that at some level does make sense]. The problem in my view is that [exactly what you've said below] people depend on it and therefore start writing non-portable code, without even knowing it. That I think is bad. Is there a warning? I bet you clang-cl will make a mess of the code that works so well with MSVC. Please confirm that you still want me to file a bug, iff yes, I'll do so. degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*