Preprocessor: Evaluate INT_MIN / -1 to 0.
This division is undefined behaviour which raises SIGFPE on x86. Most C++ preprocessors evaluate this silently to 0.
This commit is contained in:
parent
a50b107e62
commit
dc756a61c8
4 changed files with 20 additions and 1 deletions
|
|
@ -84,6 +84,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <climits>
|
||||
|
||||
#include "PpContext.h"
|
||||
#include "PpTokens.h"
|
||||
|
|
@ -350,7 +351,7 @@ namespace {
|
|||
int op_add(int a, int b) { return a + b; }
|
||||
int op_sub(int a, int b) { return a - b; }
|
||||
int op_mul(int a, int b) { return a * b; }
|
||||
int op_div(int a, int b) { return a / b; }
|
||||
int op_div(int a, int b) { return a == INT_MIN && b == -1 ? 0 : a / b; }
|
||||
int op_mod(int a, int b) { return a % b; }
|
||||
int op_pos(int a) { return a; }
|
||||
int op_neg(int a) { return -a; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue