3 ms·
I don't want to give to much credibility to the benchmark OP posted because it is quite flawed, but MSVC performs absolutely terribly on that benchmark, far wor
by Maxatar 2y ago
I don't want to give to much credibility to the benchmark OP posted because it is quite flawed, but MSVC performs absolutely terribly on that benchmark, far worse than GCC or clang with a 58x slowdown when compiled in 64-bit mode. I can only imagine how much worse it would be if compiled in 32-bit mode since MSVC in 32-bit mode does not use zero cost exception handling but uses a frame based, setup/teardown exception handling mechanism.
The exception handling you're referring to about pinging back to Win32 I presume is structured exception handling, which is not the default exception handling mechanism used by MSVC, is not recommended to be used, and is not at all performance sensitive.
This advice comes from Microsoft themselves:
https://learn.microsoft.com/en-us/cpp/cpp/exception-handling-in-visual-cpp?view=msvc-170 https://learn.microsoft.com/en-us/cpp/cpp/exception-handling...
The C++ exception handling mechanism that is used by default does not "ping back" into Win32.
- pjmlp 2y agoI guess my recollection was wrong then. However the point still stands, that isn't something compiler vendors see commercial value so to speak, when they are so constrained to keep up with ISO revisions, and a big slice of the customer base keeps disabling them.
- soulbadguy 2y agoIn general, yes i would agree that modern C++ compiler could do a much better job on exception enable code, especially in term of data flow analysis. But in this case, the benchmark it's self is kinda flawed. The semantic of the two code a very different so there isn't much the compiler could have (reasonably done).
- ack_complete 2y agoMSVC's C++ exceptions are based on Win32 exceptions, and are visible from an SEH handler. They're thrown via RaiseException() with an exception code of 0xE06D7363. Although mixing them is not recommended due to optimization concerns, C++EH scopes will unwind upon throwing an SEH exception and vice versa.