delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/05/07/22:35:58

From: jonathan AT westwood DOT com (Jonathan Lanier)
Subject: I found another compiler bug!
7 May 1997 22:35:58 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <Pine.SOL.3.91.970507151001.29829A.cygnus.gnu-win32@westmain>
Mime-Version: 1.0
Original-To: Win32 Mailing List <gnu-win32 AT cygnus DOT com>
Original-cc: colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp
Original-Sender: owner-gnu-win32 AT cygnus DOT com

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime AT docserver DOT cac DOT washington DOT edu for more info.

---559023410-851401618-863043406=:29829
Content-Type: TEXT/PLAIN; charset=US-ASCII

Attached is an example of a serious bug in the GCC compiler.  The gist of 
it is, if you use packed structures in GCC, and then attempt to use 
bitfields in those packed structures, the compiler completely 
miscalculates the offsets for the data in the structure.

This example demonstrates a C++ class containing only 2 members.  Each 
one is initialized separately, and the resulting answers printed for each 
member should be different, but they are not.  Removing the 
__attribute__((packed)) keyword gets rid of the error, but it means you 
can't pack your structures, which in my case is something I really need 
to do!

Does anyone know if this bug was previously known, or if it exists on 
other architectures?

- Jonathan
  jonathan AT westwood DOT com

---559023410-851401618-863043406=:29829
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="bits.cpp"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine DOT SOL DOT 3 DOT 91 DOT 970507151646 DOT 29829B AT westmain>
Content-Description: 

I2luY2x1ZGUgPHN0ZGlvLmg+DQ0KDQ0KDQ0KY2xhc3MgQmFkQml0cw0NCnsN
DQoJcHVibGljOg0NCgkJQmFkQml0cyh1bnNpZ25lZCBkdW1teSk7DQ0KDQ0K
CQl1bnNpZ25lZCBCaXRCcmFpbjoxOw0NCgkJdW5zaWduZWQgRHVtbXk7DQ0K
fSBfX2F0dHJpYnV0ZV9fKChwYWNrZWQpKTsNDQoNDQoNDQpCYWRCaXRzOjpC
YWRCaXRzKHVuc2lnbmVkIGR1bW15KQ0NCgk6IEJpdEJyYWluKGZhbHNlKSwg
RHVtbXkoZHVtbXkpDQ0Kew0NCn0NDQoNDQoNDQppbnQgbWFpbih2b2lkKTsN
DQoNDQoNDQppbnQgbWFpbih2b2lkKQ0NCnsNDQoJQmFkQml0cyBNeUJhZEJp
dHMoMSk7DQ0KDQ0KCXByaW50ZigiTXlCYWRCaXRzLkJpdEJyYWluIGlzICVk
XG4iLCAoaW50KU15QmFkQml0cy5CaXRCcmFpbik7DQ0KCXByaW50ZigiICAg
TXlCYWRCaXRzLkR1bW15IGlzICVkXG4iLCAoaW50KU15QmFkQml0cy5EdW1t
eSk7DQ0KDQ0KDQ0KCXByaW50ZigiXG4gICAgICBBZGRyZXNzIG9mIE15QmFk
Qml0czogMHglbHhcbiIsICh1bnNpZ25lZCBsb25nKSZNeUJhZEJpdHMpOw0N
CglwcmludGYoIkFkZHJlc3Mgb2YgTXlCYWRCaXRzLkR1bW15OiAweCVseFxu
IiwgKHVuc2lnbmVkIGxvbmcpJk15QmFkQml0cy5EdW1teSk7DQ0KDQ0KCXJl
dHVybigwKTsNDQp9DQ0K
---559023410-851401618-863043406=:29829--
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019