From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20983 invoked by alias); 17 Feb 2015 15:04:07 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 20927 invoked by uid 48); 17 Feb 2015 15:04:02 -0000 From: "dirk.bonne@inform-ac.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/65090] New: GCC produces instruction with bad alignment on SPARC when using -O Date: Tue, 17 Feb 2015 15:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.7.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dirk.bonne@inform-ac.com X-Bugzilla-Status: UNCONFIRMED 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 attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg01904.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65090 Bug ID: 65090 Summary: GCC produces instruction with bad alignment on SPARC when using -O Product: gcc Version: 4.7.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: dirk.bonne@inform-ac.com Created attachment 34789 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34789&action=edit Complete source code $ uname -a SunOS uxs450 5.10 Generic_150400-17 sun4v sparc sun4v Solaris $ g++-4.7 -v Using built-in specs. COLLECT_GCC=g++-4.7 COLLECT_LTO_WRAPPER=/opt/its/runtime/gcc/4.7/libexec/gcc/sparc-sun-solaris2.10/4.7.4/lto-wrapper Target: sparc-sun-solaris2.10 Configured with: /SSD/compile/toolsexternal/packages/gcc-4.7/work/gcc-4.7.4/configure --prefix=/opt/its/runtime/gcc/4.7 --program-suffix=-4.7 --enable-languages=c,c++ --disable-multilib --disable-nls --enable-threads=posix --enable-__cxa_atexit --enable-libstdcxx-debug --with-gnu-as --with-gnu-ld Thread model: posix gcc version 4.7.4 (GCC) I got it down to two small files (see attachment). Reproduce it like this: $ g++-4.7 -O -std=gnu++11 -c t.cc $ g++-4.7 -O -std=gnu++11 -c t2.cc $ g++-4.7 -O -std=gnu++11 -c t.cc $ g++-4.7 -O -std=gnu++11 -c t2.cc $ g++-4.7 -o t t.o t2.o $ ./t Bus Error (core dumped) The code generated for "somefunction" is broken: 00010a68 <_Z12somefunctionv>: 10a68: 9d e3 bf 80 save %sp, -128, %sp 10a6c: c0 27 bf e4 clr [ %fp + -28 ] 10a70: c0 27 bf e8 clr [ %fp + -24 ] 10a74: c0 27 bf ec clr [ %fp + -20 ] 10a78: c0 27 bf f0 clr [ %fp + -16 ] 10a7c: c0 27 bf fb clr [ %fp + -5 ] ... "%fp - 5" is not 4 bytes aligned and causes the bus error. The function somefunction is in t.cc (attached), the relevant part is: struct X { size_t a = 0; std::vector vec_; X() { vec_.emplace_back(nullptr); } }; void somefunction() { X cv; f2(string()); }