[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with c
From: |
Markus Mützel |
Subject: |
[Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang |
Date: |
Wed, 23 Mar 2022 12:30:00 -0400 (EDT) |
Follow-up Comment #4, bug #62212 (project octave):
Hmm..
g++ only gets this exactly right when compiling without optimization (which
might be the default on Ubuntu?):
$ g++ -O0 -otest_cast test_cast.cc
$ ./test_cast
db_large_integer: 1.84467e+19
ui64_large_integer: 0
$ g++ -O1 -otest_cast test_cast.cc
$ ./test_cast
db_large_integer: 1.84467e+19
ui64_large_integer: 18446744073709551615
... and the same for `-O2` and `-O3`. Maybe the default optimization level is
different for your system.
Do we compile Octave with `-O0`?
clang++ gets it always wrong (but differently depending on optimization
level):
$ clang++ -O0 -otest_cast test_cast.cc
$ ./test_cast
db_large_integer: 1.84467e+19
ui64_large_integer: 9223372036854775808
$ clang++ -O1 -otest_cast test_cast.cc
$ ./test_cast
db_large_integer: 1.84467e+19
ui64_large_integer: 4202531
... and the same for `-O2` and `-O3`.
All of those are too far off for the test case.
I wonder if there are tricks to avoid optimizations here or use different code
paths when the compiler generates code.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62212>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Arun Giridhar, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Arun Giridhar, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang,
Markus Mützel <=
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Arun Giridhar, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, John W. Eaton, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, John W. Eaton, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Markus Mützel, 2022/03/23
- [Octave-bug-tracker] [bug #62212] Wrong unsigned integer overflow with clang, Arun Giridhar, 2022/03/23