[Bug c++/82246] New: Wrong optimisation of an offset double* attribute class allocated in stack

erwan.adam at cea dot fr gcc-bugzilla@gcc.gnu.org
Tue Sep 19 09:15:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82246

            Bug ID: 82246
           Summary: Wrong optimisation of an offset double* attribute
                    class allocated in stack
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: erwan.adam at cea dot fr
  Target Milestone: ---

Created attachment 42204
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42204&action=edit
Use case for wrong optimisation of an offset double* attribute class allocated
in stack

The code in attachment fails with -O1 :

[adam]$ g++ -O0 -Wall -pedantic -Wextra -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations main.cxx && ./a.out 
0
1 1
2 2
 POMOT3 - Convergency ok
[adam]$ g++ -O1 -Wall -pedantic -Wextra -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations main.cxx && ./a.out
0
1 1
2 1
3 1
4 1
5 1
 POMOT3 - Convergency failed

This code is valgrind free errors but works in O1 with -fsanitize=undefined :

[adam]$ g++ -O1 -Wall -pedantic -Wextra -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -fsanitize=undefined main.cxx && ./a.out
0
1 1
2 2
 POMOT3 - Convergency ok


More information about the Gcc-bugs mailing list