63 points · by cppdesign · 11y ago · 13 comments
In case anyone else is wondering "why didn't they just use STL?", here's an answer from an Unreal employee: https://answers.unrealengine.com/questions/2695/rocket-and-t...
Is this just a way to force a segfault, or clever sorcery? What is significant about the pointer 3?
http://en.wikipedia.org/wiki/INT_%28x86_instruction%29
I'd prefer to see this either with inline assembly, or using __debugbreak() (and variants for other compilers). I'd say it's a deref because many compilers don't generate inline-asm for 64-bit skus. This makes the instruction always emitted, and then 64-bit platforms ignore it. But not always (recent claims say it works: http://stackoverflow.com/questions/3634124/where-did-int-3-g...).
It's a forced memory access violation and the 3 is used to distinguish it from a natural one: when you hit this you will see an immediate 3 load nearby and that's a constant that is rarely seen in code normally.
Technically no, however it's only used in x86. It's only ever called if PLATFORM_EXCEPTIONS_DISABLED is 0. If you look up where PLATFORM_EXCEPTIONS_DISABLED is defined in Platform.h, you'll see it's only defined when not using PLATFORM_DESKTOP. PLATFORM_DESKTOP is disabled for Android, HTML5, iOS, WinRT, and WinRTArm. PLATFORM_DESKTOP is enabled for Linux, Mac, and Windows. So that instruction is only intended to be used in x86 desktop environments.
Considering this, I don't think RaiseException is well defined. If it's only meant to be used for x86, it should be coded that way instead of relying on other code to enforce the behavior.