[PATCH] [compiler-rt] [ubsan] Print dynamic integer values in both decimal and hexadecimal

Dmitri Gribenko gribozavr at gmail.com
Wed Feb 27 07:56:52 PST 2013


On Wed, Feb 27, 2013 at 12:28 AM, Will Dietz <wdietz2 at illinois.edu> wrote:
> (Attached).
>
> Many integer errors are easier to understand once you see the hex
> representation of the operands involved.
>
> Update tests accordingly.

-  // CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: runtime error:
signed integer overflow: 305419896 + 2023406814 cannot be represented
in type 'int'
+  // CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: runtime error:
signed integer overflow: 305419896 [=0x12345678] + 2023406814
[=0x789abcde] cannot be represented in type 'int'

I don't think it is easy to read.  Could you think of an alternative
way to print this?  For example, "<decimal> + <decimal> [in hex: <hex>
+ <hex>]" might be better when printing expressions.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the llvm-commits mailing list