Skip to content

Commit 454cb02

Browse files
committed
Added workaround for armc assumptions on integer underflow
With ARM Compiler 5.06u3, when the equeue_tickdiff function is inlined, the compiler treats the unsigned integer subtraction as undefined behaviour and assumes falsely the comparisons could never be true. The workaround is to an explicit cast, which politely reminds the compiler to emit the correct comparison.
1 parent b392561 commit 454cb02

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

equeue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// calculate the relative-difference between absolute times while
1414
// correctly handling overflow conditions
1515
static inline int equeue_tickdiff(unsigned a, unsigned b) {
16-
return (int)(a - b);
16+
return (int)(unsigned)(a - b);
1717
}
1818

1919
// calculate the relative-difference between absolute times, but

0 commit comments

Comments
 (0)