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/98069] New: Miscompilation with -O3
Date: Mon, 30 Nov 2020 15:04:53 +0000	[thread overview]
Message-ID: <bug-98069-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98069
           Summary: Miscompilation with -O3
           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: ---

Reproducer:
//func.cpp
extern long long var_3;
extern short var_8;
extern int var_17;
extern short arr_165[];
long c(long e, long f) { return f ? e : f; }
void test() {
    for (int b = 0; b < 19; b = var_17)
        for (int d = int(~c(-2147483647 - 1, var_3)) - 2147483647; d < 22; d++)
            arr_165[d] = var_8;
}

//driver.cpp 
#include <stdio.h>

long long int var_3 = -166416893043554447LL;
short var_8 = (short)27092;
unsigned int var_17 = 75036300U;
short arr_165[23];

void test();

int main() {
    for (size_t i_3 = 0; i_3 < 23; ++i_3)
        arr_165[i_3] = (short)-8885;
    test();
    printf("%d\n", arr_165[0]);
}

>$ g++ -O3 func.cpp driver.cpp && ./a.out
Segmentation fault (core dumped)
>$ g++ -O2 func.cpp driver.cpp && ./a.out
27092

gcc version 11.0.0 20201126 (beb9afcaf1466996a301c778596c5df209e7913c)

             reply	other threads:[~2020-11-30 15:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 15:04 vsevolod.livinskij at frtk dot ru [this message]
2020-11-30 16:29 ` [Bug tree-optimization/98069] [8/9/10/11 Regression] Miscompilation with -O3 since r8-2380-g2d7744d4ef93bfff marxin at gcc dot gnu.org
2020-11-30 16:29 ` marxin at gcc dot gnu.org
2020-12-01  8:33 ` rguenth at gcc dot gnu.org
2020-12-01  8:33 ` rguenth at gcc dot gnu.org
2020-12-01  9:41 ` rguenth at gcc dot gnu.org
2020-12-02  8:38 ` rguenth at gcc dot gnu.org
2020-12-04 13:23 ` rguenth at gcc dot gnu.org
2021-01-08 14:39 ` rguenth at gcc dot gnu.org
2021-04-23  9:20 ` [Bug tree-optimization/98069] [8/9/10 " rsandifo at gcc dot gnu.org
2021-04-23  9:21 ` rsandifo at gcc dot gnu.org
2021-04-23  9:21 ` rsandifo at gcc dot gnu.org
2022-06-28 10:42 ` [Bug tree-optimization/98069] [10 " jakub at gcc dot gnu.org
2023-07-07  9:15 ` rguenth 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-98069-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).