From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A8271386180C; Wed, 12 Aug 2020 19:03:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8271386180C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597259022; bh=jTlEj45lQvVukW5fxdvOHF312z3b1l49rgrl/SOCLgo=; h=From:To:Subject:Date:From; b=BfED3bYMXCSDGLJc7stn5vg5keDYF5wNZrOyqYX6i8/TSC8hQoibG8lji/x48dzga nwZ/cyZl0bb7tCPgGsDY9YbJvQNR7TA3i8TbGnrVdAd/trd8HTyVRgXJ3hq7b67j2s f4WCDvRClRxWQntYPWSocYZtwe3ujf/SeZwFDcBQ= From: "mitya57 at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mitya57 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Aug 2020 19:03:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96594 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=3D49050&action=3Dedit 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 beha= ves 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 =3D 0x1020304 got value =3D 0xffffffff $ g++ test.cpp -g -O0 -lX11 $ xvfb-run ./a.out setting value =3D 0x1020304 got value =3D 0x0 And both these behaviors are wrong! Expected behavior is (as seen on x86_64= ): $ xvfb-run ./a.out=20 setting value =3D 0x1020304 got value =3D 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 chan= ge, 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 make= s 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.=