octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with c


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang
Date: Wed, 23 Mar 2022 12:18:37 -0400 (EDT)

Follow-up Comment #3, bug #62212 (project octave):

I can now reproduce your numerical results for GCC and Clang. Took some
debugging but got there in the end.

With the sanitizer flags, the difference in behavior is more apparent:


$ g++ -fsanitize=address,undefined clangtest.cpp && ./a.out
db_large_integer: 1.84467e+19
ui64_large_integer: 0

$ clang++ -fsanitize=address,undefined clangtest.cpp && ./a.out
db_large_integer: 1.84467e+19
clangtest.cpp:8:33: runtime error: 1.84467e+19 is outside the range of
representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior clangtest.cpp:8:33 in

ui64_large_integer: 9223372036854775808


Also to note: GCC gives "ui64_large_integer: 18446744073709551615" for any
optimization flag like -O1, -O2 and -O3, anything other than -O0. With any of
those flags, Clang gives the junk value near 2^46 which moreover changes with
every execution.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62212>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]