public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mitya57 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/96594] New: Compiled code behaves differently with -O1 and -O0 on s390x
Date: Wed, 12 Aug 2020 19:03:42 +0000	[thread overview]
Message-ID: <bug-96594-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 96594
           Summary: Compiled code behaves differently with -O1 and -O0 on
                    s390x
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mitya57 at gmail dot com
  Target Milestone: ---

Created attachment 49050
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49050&action=edit
Test case

Hi,

I was debugging Compiz test failures that started happening on Debian/Ubuntu
s390x in July. They are not directly related to GCC upgrade (old GCC 8 behaves
the same way), however I noticed a strange thing that I want to report here.

The attached file behaves differently when built with -O0 and -O1:

$ g++ test.cpp -g -O1 -lX11
$ xvfb-run ./a.out
setting value = 0x1020304
got value = 0xffffffff

$ g++ test.cpp -g -O0 -lX11
$ xvfb-run ./a.out
setting value = 0x1020304
got value = 0x0

And both these behaviors are wrong! Expected behavior is (as seen on x86_64):

$ xvfb-run ./a.out 
setting value = 0x1020304
got value = 0x1020304

However, this bug is about differing behaviors with -O1 and -O0.

The only dependency of this file is Xlib. So far I was not able to make an
example that does not depend on it.

I wanted to bisect a particular optimization that causes this behavior change,
but even with all options from
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-O1 it behaves
like -O0.

Some more things I noticed:

- Moving GetProperty and SetProperty functions away from the namespace makes it
behave like -O0.

- Adding __attribute__((noinline)) to SetProperty makes it behave like -O0. So
the bug may be related to inlining.

I am also attaching assembly dumps with -O1 and -O0.

             reply	other threads:[~2020-08-12 19:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 19:03 mitya57 at gmail dot com [this message]
2020-08-12 19:04 ` [Bug c++/96594] " mitya57 at gmail dot com
2020-08-12 19:04 ` mitya57 at gmail dot com
2020-08-12 19:40 ` jakub at gcc dot gnu.org
2020-08-12 20:12 ` mitya57 at gmail dot com

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-96594-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).