public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/65090] New: GCC produces instruction with bad alignment on SPARC when using -O
@ 2015-02-17 15:04 dirk.bonne@inform-ac.com
  2015-02-17 15:52 ` [Bug middle-end/65090] " mikpelinux at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dirk.bonne@inform-ac.com @ 2015-02-17 15:04 UTC (permalink / raw)
  To: gcc-bugs

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<X*> vec_;

    X() {
      vec_.emplace_back(nullptr);
    }
  };
  void somefunction()
  {
    X cv;
    f2(string());
  }


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-01 18:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-17 15:04 [Bug middle-end/65090] New: GCC produces instruction with bad alignment on SPARC when using -O dirk.bonne@inform-ac.com
2015-02-17 15:52 ` [Bug middle-end/65090] " mikpelinux at gmail dot com
2015-02-17 17:20 ` jakub at gcc dot gnu.org
2015-02-18  8:54 ` dirk.bonne@inform-ac.com
2015-02-24 18:12 ` [Bug c++/65090] " ebotcazou at gcc dot gnu.org
2015-07-01 18:01 ` jason at gcc dot gnu.org
2015-07-01 18:07 ` jason at gcc dot gnu.org

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