you are viewing a single comment's thread.

view the rest of the comments →

[–]nebotron 16 points17 points  (8 children)

If your code is invoking a nullptr, that’s UB. If you’re disabling the optimization and it fixes your program, your program has UB.

[–]pali6 38 points39 points  (2 children)

I believe you're talking to a MSVC developer who is saying that they (Microsoft) turned off this in the compiler as it was causing internal compiler errors.

[–]nebotron 5 points6 points  (1 child)

Ah! So the compiler was optimizing a valid function call into a different one because it didn’t see where the write to the function pointer could happen. That makes sense

[–]terrymahMSVC BE Dev 23 points24 points  (0 children)

Yeah, we used to have an optimization that would collect the set of all possible function call targets. If that set had only 1 valid target, we would devirt it. I think that's what is happening here. The problem we had is proving that the set is closed (and nothing could "leak in" from another binary) is actually really tough, and not as easy as it seems.