Documentation states that "You must use /EHa when using _set_se_translator.".
My question is: should /EHa be used for all files in project/ all files in project that catch exceptions or just in the file that calls _set_se_translator ?
Asked
Active
Viewed 2,032 times
1

cprogrammer
- 5,503
- 3
- 36
- 56
2 Answers
2
You need it not just for functions that catch exceptions, but also functions that throw and propagate them. The actual call to _set_se_translator
itself probably doesn't need to be compiled with /Eha, but why be inconsistent?

MSalters
- 173,980
- 10
- 155
- 350
-
as far as I have read using /Eha involves security issues and it is not good practice. And may result in a less performant image because the compiler will not optimize a try block as aggressively, even if the compiler does not see a throw. – cprogrammer Nov 04 '11 at 14:38
-
Security issues? Don't think so. It _is_ less performent, yes. You've massively increased the number of instructions that can cause C++ exceptions to be thrown. – MSalters Nov 04 '11 at 14:56
-
do you know how less efficient it is ? Maybe I should use SEH and convert exceptions myself. – cprogrammer Nov 04 '11 at 14:59
-
Doesn't matter a whole lot in reasonable code (i.e. not throwing thousands of exceptions per second). – MSalters Nov 04 '11 at 15:08
2
After checking I must disagree with what has been said before about all instances needed to be compiled with /EHa. I made a small program with:
crashing code
__declspec(dllexport) void crashMe() { *((int*)0)=0; }
in a DLL compiled without any exception handling at all
- calling code elsewhere in a try/catch
Then
- Unless the calling code is compiled with /EHa the program will crash
- Without
_set_se_translator
the exception can only be caught incatch(...)

reder
- 1,098
- 7
- 9
-
thanks for the investigation ! The OP might have been in the same situation: using Boost.Test with an already compiled library, and I can enable /EHa only for the test file object – Raphaël Londeix Jun 29 '15 at 07:30