unexpected result with -O2 solved via "volatile"
Marc Glisse
marc.glisse@inria.fr
Sun Sep 19 18:56:02 GMT 2021
On Sun, 19 Sep 2021, Allin Cottrell via Gcc wrote:
> Should this perhaps be considered a bug? Below is a minimal test case for a
> type of calculation that occurs in my real code. It works as expected when
> compiled without optimization, but produces what seems like a wrong result
> when compiled with -O2, using both gcc 10.3.1 20210422 on Fedora and gcc
> 11.1.0-1 on Arch Linux. I realize there's a newer gcc release but it's not
> yet available for Arch, and looking at
> https://gcc.gnu.org/gcc-11/changes.html I didn't see anything to suggest that
> something relevant has changed.
https://gcc.gnu.org/bugs/ says that you should first try compiling your
code with -fsanitize=undefined, which tells you at runtime that your code
is broken.
Apart from that, bug reports should go to https://gcc.gnu.org/bugzilla/
and questions to gcc-help@gcc.gnu.org.
--
Marc Glisse
More information about the Gcc
mailing list