public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/57344] New: wrong code with pragma pack(1) and -O1 on x86
@ 2013-05-20 21:38 dhazeghi at yahoo dot com
  2013-05-21  8:19 ` [Bug middle-end/57344] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dhazeghi at yahoo dot com @ 2013-05-20 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57344
           Summary: wrong code with pragma pack(1) and -O1 on x86
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

The following code produces wrong output on x86_64-linux-gnu in 32-bit mode,
when compiled at -O1 or higher optimizations.  It appears that the behavior
changed between gcc 4.6 which works at all optimization levels, and 4.7 which
does not.

$ gcc-trunk -v
gcc version 4.9.0 20130520 (experimental) [trunk revision 199099] (GCC) 
$ gcc-trunk -O0 -m32 wrong.c 
$ ./a.out 
-3161
$ gcc-trunk -O1 -m64 wrong.c 
$ ./a.out 
-3161
$ gcc-4.6 -O1 -m32 wrong.c 
$ ./a.out 
-3161
$ gcc-trunk -O1 -m32 wrong.c 
$ ./a.out 
2093991
$
--------------------------
int printf(const char *, ...);

#pragma pack(1)
struct S0
{
    int f0:11;
    int f1:22;
    char f2;
    int:0;
}
s[2];
int i;
int
main ()
{
    struct S0 tmp = { 0, -3161L };
    s[1] = tmp;
    for (; i < 1; i++)
        printf ("%d\n", s[1].f1);
    return 0;
}


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

end of thread, other threads:[~2014-06-12 13:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-20 21:38 [Bug target/57344] New: wrong code with pragma pack(1) and -O1 on x86 dhazeghi at yahoo dot com
2013-05-21  8:19 ` [Bug middle-end/57344] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
2013-05-21  9:08 ` [Bug rtl-optimization/57344] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
2013-05-21  9:15 ` jakub at gcc dot gnu.org
2013-05-21 10:18 ` jakub at gcc dot gnu.org
2013-05-23  9:21 ` [Bug rtl-optimization/57344] [4.7 " jakub at gcc dot gnu.org
2014-06-12 13:27 ` rguenth 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).