Question

It seems that SetErrorMode(SEM_NOGPFAULTERRORBOX), suppresses division by zero.

Code to reproduce:

SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); // Comment out this line and an error dialog will appear.
int a = 5;
printf("%d", 1/(a-5));

Why is that? From the name I assume it should suppress only General Protection Fault, which has nothing to do with division by zero.

Was it helpful?

Solution

From the MSDN reference page:

The system does not display the Windows Error Reporting dialog.

This means that when you set the flag, it suppresses all error dialogs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top