public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vsevolod.livinskij at frtk dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/95396] New: GCC produces incorrect code with -O3 for loops
Date: Thu, 28 May 2020 20:44:27 +0000	[thread overview]
Message-ID: <bug-95396-4@http.gcc.gnu.org/bugzilla/> (raw)

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)

             reply	other threads:[~2020-05-28 20:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 20:44 vsevolod.livinskij at frtk dot ru [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95396-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).