[Bug middle-end/65090] New: GCC produces instruction with bad alignment on SPARC when using -O

2015-02-17 Thread dirk.bo...@inform-ac.com
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.bo...@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());
  }


[Bug middle-end/65090] GCC produces instruction with bad alignment on SPARC when using -O

2015-02-18 Thread dirk.bo...@inform-ac.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65090

--- Comment #3 from Dirk Bonne  ---
The bug is elusive --- I then hope it is really gone from later versions and
not just hidden...