From 326091624cf79f7f78cc930e3a62b31e8297ea44 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Mon, 21 Jan 2019 16:22:10 +0100 Subject: [PATCH] Fix non-compliance problem with octal/hex literals without U suffix To follow the standard, hexadecimal and octal values that don't fit an intmax_t must be of type uintmax_t, regardless of the presence of the U suffix. --- cpreproc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpreproc.py b/cpreproc.py index d1ebcbf..69a32d3 100644 --- a/cpreproc.py +++ b/cpreproc.py @@ -317,7 +317,10 @@ class Evaluator(object): raise EvalError("Invalid integer literal") val = (int(m.group(2), 8) if m.group(2) else int(m.group(1) or m.group(3), 0)) - val = self.to_uint(val) if m.group(4) else self.to_sint(val) + val = (self.to_uint(val) + if m.group(4) + or val >= -INTMAX_MIN and m.group(3) is None + else self.to_sint(val)) return val if tok.type == 'CPP_STRING':