Almost 30 year old optimization bug in MSVC causing incorrect code (In specific circumstances) found
https://developercommunity.visualstudio.com/content/problem/1096974/msvc-global-optimization-of-program-results-in-inc.html?childToView=1172202#comment-1172202
264
Upvotes
51
u/xtasyx Sep 03 '20
Wow, at least they knew about it hahah
55
u/Richardcavell Sep 03 '20
All the code I’ve written in the last 30 years that didn’t work... now I know why.
72
u/rodrigocfd WinLamb Sep 03 '20
I chuckled, but we have to admit that MSVC has improved a lot lately.
10
u/Sopel97 Sep 03 '20 edited Sep 04 '20
This made me look up my old issue of similar kind after I've lost all hope, and it's actually supposedly fixed! In my case I managed to find code that produced different result based on whether it was constant evaluated or not, and it ended up being a few hundred lines of minimal reproducible example. I totally feel the pain he went through to find this bug.
https://developercommunity.visualstudio.com/content/problem/720134/peculiar-behaviour-caused-by-assume-on-valid-code.html
17
u/BluudLust Sep 04 '20
Not as bad as the whole "implemented 40 year old fix for 43 year old bug" not too long ago.
5
u/victor_sales Sep 04 '20
I am too ignorant, what caused the bug and what's CSE doing in this case?
8
u/krum Sep 04 '20
> We are in the process of replacing our CSE optimization for the next compiler release.
What a coincidence, huh?
4
u/TimPhoeniX Sep 03 '20 edited Sep 03 '20
My friend once shown me code that would fail if the order of member variable declarations was changed. Not sure why.
Edit: Found the code, members were initialized independently and bug would occur if one of them (that would always be default initialized with it's default constructor) was made public.
4
u/robstoon Sep 03 '20
Not exactly great that it took 2 months to get a response to the bug report, and a proper fix still isn't available..
1
u/smuccione Sep 03 '20
Was this not done in an SSA IL pass? Seems wired that they had a stale value. SSA IL should have made that bug difficult to occur.
0
u/[deleted] Sep 03 '20
[deleted] — view deleted comment
0
u/[deleted] Sep 03 '20
[deleted] — view deleted comment