public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33205]  New: bitfield optimizations causes corrupt bitfield expansion at runtime
@ 2007-08-27 16:03 xk-corpse at hotmail dot com
  2007-08-28  8:45 ` [Bug c++/33205] optimization bug: unsigned bitfield expands with non-zero padding bits xk-corpse at hotmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: xk-corpse at hotmail dot com @ 2007-08-27 16:03 UTC (permalink / raw)
  To: gcc-bugs

test.cxx
------------------------------------------------------
#include <iostream>

struct A
{
    unsigned short x:14;
    unsigned short y:14;
};


extern unsigned n;

int main()
{
    A a;

    a.x = n & 0x3FFF;
    a.y = (n>>14) & 0x3FFF;

    unsigned expected = n & 0x3FFF;

    if( a.x != expected )
    {
        std::cout << "test failed: "
            << " (x=" << a.x
            << ") != " << expected
            << ", y=" << a.y
            << std::endl;
        return 1;
    }

    std::cout << "test succedeed" << std::endl;

    return 0;
}

unsigned n = 0xFE7B4873U;
------------------------------------------------------

output:
test failed:  (x=18547) != 2163, y=14829

14-bit unsigned field expands with non-zero padding bits


appears with gcc-4.2.1, gcc-4.1.2, gcc-4.2-20070822
does not appear with gcc-3.4.6

gcc was configured and built with crosstool-0.43 (with glibc-2.3.2)

powerpc-603-linux-gnu-g++ -v
Using built-in specs.
Target: powerpc-603-linux-gnu
Configured with:
/home/corpse/tmp/interlink/crosstool-0.43/build/powerpc-603-linux-gnu/gcc-4.2.1-glibc-2.3.2/gcc-4.2.1/configure
--target=powerpc-603-linux-gnu --host=i686-host_pc-linux-gnu
--prefix=/opt/compilers/gcc-4.2.1-glibc-2.3.2/powerpc-603-linux-gnu
--with-cpu=603 --enable-cxx-flags=-mcpu=603
--with-headers=/opt/compilers/gcc-4.2.1-glibc-2.3.2/powerpc-603-linux-gnu/powerpc-603-linux-gnu/include
--with-local-prefix=/opt/compilers/gcc-4.2.1-glibc-2.3.2/powerpc-603-linux-gnu/powerpc-603-linux-gnu
--disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit
--enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.2.1


-- 
           Summary: bitfield optimizations causes corrupt bitfield expansion
                    at runtime
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: xk-corpse at hotmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: powerpc-603-linux-gnu


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


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

end of thread, other threads:[~2008-02-07 18:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-27 16:03 [Bug c++/33205] New: bitfield optimizations causes corrupt bitfield expansion at runtime xk-corpse at hotmail dot com
2007-08-28  8:45 ` [Bug c++/33205] optimization bug: unsigned bitfield expands with non-zero padding bits xk-corpse at hotmail dot com
2007-08-28  9:39 ` [Bug target/33205] " rguenth at gcc dot gnu dot org
2007-08-28 11:25 ` xk-corpse at hotmail dot com
2007-08-30 21:21 ` pinskia at gcc dot gnu dot org
2008-02-04 16:50 ` rguenth at gcc dot gnu dot org
2008-02-05 16:46 ` bergner at gcc dot gnu dot org
2008-02-07 17:33 ` janis at gcc dot gnu dot org
2008-02-07 18:04 ` rguenth at gcc dot gnu dot 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).