Have you ever had issues with the compiler removing/ignoring that line when optimizations are turned on?
No, could it? If I ever noticed it I would make it a bit more complex.
On windows you can just call DebugBreak();
Yes, but most of my code is written to be as portable as possible, if not outright cross-platform.
Mostly, if I want a break somewhere I do this:
Which will result in a crash, I attach my debugger, run the code and if it reaches that line it will break and I can inspect everything I want.It's easier than adding a __asm(int3) because it's cross platform. On windows for example it's not possible to perform inline assembly in x64 builds, and compiler intrinsics are not portable.