public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40333]  New: g++ does not align static variables properly
@ 2009-06-03 21:22 gccsse at mailinator dot com
  2009-06-03 21:26 ` [Bug c++/40333] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gccsse at mailinator dot com @ 2009-06-03 21:22 UTC (permalink / raw)
  To: gcc-bugs

The following SSE2 code crashes because the non-static global variable breaks
the alignment of the static data section.

align.cpp:

#include <emmintrin.h>
int nonstatic_padding;
static int static_padding[3];
static __attribute__((aligned(16))) __m128i sse_data;
int main() {
    static_padding[0] = 1234;
    sse_data = _mm_set1_epi32(123);
    return 0;
}

The example uses SSE2 because that's how I discovered the bug and because it
results in a nice crash, though I don't think it's essential at all.

Results:
- crashes (even when static_padding is removed)
- no longer crashes when removing nonstatic_padding (even when static_padding
is present)
- no longer crashes when making sse_data non-static

Tested with:
g++-4 (GCC) 4.3.2 20080827 (beta) 2
and g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
(I know they're a bit old, but Cygwin doesn't provide more recent binaries)

If you rename the file to align.c gcc compiles it correctly and the program
does not crash (gcc places static variables before non-static ones, unlike
g++).


-- 
           Summary: g++ does not align static variables properly
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gccsse at mailinator dot com
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40333


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

* [Bug c++/40333] g++ does not align static variables properly
  2009-06-03 21:22 [Bug c++/40333] New: g++ does not align static variables properly gccsse at mailinator dot com
@ 2009-06-03 21:26 ` pinskia at gcc dot gnu dot org
  2009-08-24  4:38 ` rogerdpack at gmail dot com
  2009-08-24  6:15 ` dannysmith at users dot sourceforge dot net
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-06-03 21:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-06-03 21:26 -------


*** This bug has been marked as a duplicate of 37216 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40333


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

* [Bug c++/40333] g++ does not align static variables properly
  2009-06-03 21:22 [Bug c++/40333] New: g++ does not align static variables properly gccsse at mailinator dot com
  2009-06-03 21:26 ` [Bug c++/40333] " pinskia at gcc dot gnu dot org
@ 2009-08-24  4:38 ` rogerdpack at gmail dot com
  2009-08-24  6:15 ` dannysmith at users dot sourceforge dot net
  2 siblings, 0 replies; 4+ messages in thread
From: rogerdpack at gmail dot com @ 2009-08-24  4:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rogerdpack at gmail dot com  2009-08-24 04:38 -------
(In reply to comment #0)
> The following SSE2 code crashes because the non-static global variable breaks
> the alignment of the static data section.

Is this fixed if you use 4.5.0?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40333


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

* [Bug c++/40333] g++ does not align static variables properly
  2009-06-03 21:22 [Bug c++/40333] New: g++ does not align static variables properly gccsse at mailinator dot com
  2009-06-03 21:26 ` [Bug c++/40333] " pinskia at gcc dot gnu dot org
  2009-08-24  4:38 ` rogerdpack at gmail dot com
@ 2009-08-24  6:15 ` dannysmith at users dot sourceforge dot net
  2 siblings, 0 replies; 4+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2009-08-24  6:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dannysmith at users dot sourceforge dot net  2009-08-24 06:15 -------
(In reply to comment #2)
> (In reply to comment #0)
> > The following SSE2 code crashes because the non-static global variable breaks
> > the alignment of the static data section.
> 
> Is this fixed if you use 4.5.0?
> 
This is fixed with 4.5.0 and a recent binutils (Nick Clifton's patch to GAS was
commuitted on 2008-09-03)
Danny


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40333


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

end of thread, other threads:[~2009-08-24  6:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-03 21:22 [Bug c++/40333] New: g++ does not align static variables properly gccsse at mailinator dot com
2009-06-03 21:26 ` [Bug c++/40333] " pinskia at gcc dot gnu dot org
2009-08-24  4:38 ` rogerdpack at gmail dot com
2009-08-24  6:15 ` dannysmith at users dot sourceforge dot net

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