public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/95396] New: GCC produces incorrect code with -O3 for loops
@ 2020-05-28 20:44 vsevolod.livinskij at frtk dot ru
  2020-05-29  6:36 ` [Bug tree-optimization/95396] " rguenth at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: vsevolod.livinskij at frtk dot ru @ 2020-05-28 20:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95396
           Summary: GCC produces incorrect code with -O3 for loops
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Error:
>$ g++ -O0 small.cpp && ./a.out 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 0 0 0 
>$ g++ -O3 small.cpp && ./a.out 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42 0 0 0 

Reproducer:
>$ cat small.cpp 
#include <stdio.h>

unsigned short arr_26 [20];
signed char arr_25 [2000];

unsigned char b;

int c(int d, int f) { return d > f ? d : f; }

void test() { 
    for (char e = c(b, 241) + 15; e < 17; e += 1)
        arr_26[e] = 42;
}

int main() {
    test();
    for (size_t i_0 = 0; i_0 < 20; ++i_0)
        printf("%d ", arr_26 [i_0]);
    printf("\n");
}

GCC version:
11.0.0 (1852a26b925970f64f8d31518ba732fe9c3ade23)

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-04-23  9:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 20:44 [Bug tree-optimization/95396] New: GCC produces incorrect code with -O3 for loops vsevolod.livinskij at frtk dot ru
2020-05-29  6:36 ` [Bug tree-optimization/95396] " rguenth at gcc dot gnu.org
2020-05-29  7:13 ` [Bug tree-optimization/95396] [8/9/10/11 Regression] GCC produces incorrect code with -O3 for loops since r8-6511-g3ae129323d150621 marxin at gcc dot gnu.org
2020-06-15  3:20 ` babokin at gmail dot com
2020-06-26 12:07 ` rguenth at gcc dot gnu.org
2020-07-06 21:42 ` babokin at gmail dot com
2020-07-07  8:00 ` rguenth at gcc dot gnu.org
2020-07-07  8:20 ` rguenth at gcc dot gnu.org
2020-07-07  8:26 ` rguenth at gcc dot gnu.org
2020-12-08 19:51 ` marxin at gcc dot gnu.org
2020-12-09  9:10 ` rguenth at gcc dot gnu.org
2020-12-09 17:03 ` rsandifo at gcc dot gnu.org
2020-12-09 19:42 ` marxin at gcc dot gnu.org
2020-12-10  9:46 ` rsandifo at gcc dot gnu.org
2020-12-10 12:11 ` [Bug tree-optimization/95396] [8/9/10 " rsandifo at gcc dot gnu.org
2021-04-23  9:21 ` rsandifo at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).