Operator precedence warnings
Closed this issue · 2 comments
wintersteiger commented
After extracting FStar_UInt128.c, gcc (gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
with some collection of -W
s) emits the following warnings. I think it's best if we always parenthesize expressions of this kind, just to avoid potential confusion. (In fact, they are parenthesized in FStar_UInt128.fst too).
FStar_UInt128.c: In function ‘FStar_UInt128_gt’:
FStar_UInt128.c:191:46: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
return a.high > b.high || a.high == b.high && a.low > b.low;
^
FStar_UInt128.c: In function ‘FStar_UInt128_lt’:
FStar_UInt128.c:196:46: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
return a.high < b.high || a.high == b.high && a.low < b.low;
^
FStar_UInt128.c: In function ‘FStar_UInt128_gte’:
FStar_UInt128.c:201:46: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
return a.high > b.high || a.high == b.high && a.low >= b.low;
^
FStar_UInt128.c: In function ‘FStar_UInt128_lte’:
FStar_UInt128.c:206:46: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
return a.high < b.high || a.high == b.high && a.low <= b.low;
beurdouche commented
I was about to open the exact same issue. It would be very useful to add parentheses, especially since HACL is compiled on -Wall -Werror
on some platforms...