public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17112] New: default operator= for struct with packed bitfield is wrong
@ 2004-08-19 23:22 gene at digilicious dot com
  2004-08-20 12:45 ` [Bug c++/17112] " bangerth at dealii dot org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: gene at digilicious dot com @ 2004-08-19 23:22 UTC (permalink / raw)
  To: gcc-bugs

#include <iostream>
                                                                               
                                                              
using namespace std;
 
struct myint24 {
  int int24:24  __attribute__ ((packed)); 
};
 
myint24 x[3] = {
  0x123456,
  0x789abc,
  0xdef012
};
 
myint24 y[3];            // starts out as zeros
 
int main(int ac, char* av[])
{
  y[1] = x[1];           // should only copy 3 bytes
  for ( int i=0; i<3; ++i )
    if ( 0 != y[i].int24 )
      cout << i << endl; // should only find one non-zero element, and print "1"
  return 0;
}

// compile with default options

// the output should be "1" but it's not

// the bug exists in 3.4.1 and 3.5.0 cvs snapshot from 20040818
// also in 3.3 versions, but not in 3.2

// I don't expect you need the preprocessed sources in this case, since
// the example is so small.

-- 
           Summary: default operator= for struct with packed bitfield is
                    wrong
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gene at digilicious dot com
                CC: gcc-bugs at gcc dot gnu dot org,gene at digilicious dot
                    com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2004-09-27 14:07 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-19 23:22 [Bug c++/17112] New: default operator= for struct with packed bitfield is wrong gene at digilicious dot com
2004-08-20 12:45 ` [Bug c++/17112] " bangerth at dealii dot org
2004-08-20 12:50 ` bangerth at dealii dot org
2004-08-20 20:23 ` gene at digilicious dot com
2004-09-23  2:48 ` [Bug middle-end/17112] Copying of packed bitfields " giovannibajo at libero dot it
2004-09-23  3:36 ` giovannibajo at libero dot it
2004-09-23 13:03 ` roger at eyesopen dot com
2004-09-23 13:16 ` giovannibajo at libero dot it
2004-09-23 13:29 ` roger at eyesopen dot com
2004-09-23 14:50 ` giovannibajo at libero dot it
2004-09-24  3:03 ` giovannibajo at libero dot it
2004-09-25  9:45 ` giovannibajo at libero dot it
2004-09-26 14:58 ` cvs-commit at gcc dot gnu dot org
2004-09-26 15:16 ` pinskia at gcc dot gnu dot org
2004-09-27 10:06 ` schwab at suse dot de
2004-09-27 10:09 ` schwab at suse dot de
2004-09-27 12:55 ` pinskia at gcc dot gnu dot org
2004-09-27 13:20 ` pinskia at gcc dot gnu dot org
2004-09-27 14:07 ` schwab at suse dot de

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