Fwd: g++ serious bug in Ubuntu Lucid Lynx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, forgot to CC the following message to gcc-help:


---------- Forwarded message ----------
From: John Graham <johngavingraham@xxxxxxxxxxxxxx>
Date: Wed, Jun 2, 2010 at 5:13 PM
Subject: Re: g++ serious bug in Ubuntu Lucid Lynx
To: "David R. Doucette" <ddoucette@xxxxxxxxxxxxxxxx>


You can use the variable attributes
(http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html),
specifically `aligned' and `packed' to achieve what you want. For
example, with the following code:


// start
#include <stdio.h>

struct s {
   short int x __attribute__((__aligned__(2)));
   int y __attribute__((__packed__));
};

int main(void) {
   printf("offset of y:      %d\n", __builtin_offsetof(struct s, y));
   printf("size of struct s: %d\n", sizeof(struct s));
}
// end


The result is that the offset of y in struct s is 2 and the overall
size is 6. Without the attributes (e.g. if you were to add #define
__attribute__(x)' after the #include) the results are 4 and 8, on my
machine.

Hope this helps.

John G



On Wed, Jun 2, 2010 at 4:53 PM, David R. Doucette
<ddoucette@xxxxxxxxxxxxxxxx> wrote:
> We just installed Lucid Lynx a few days ago, and have hit a fatal flaw with
> g++ that has forced us to stop the deployment and roll back the systems we
> could.
>
> Structures in Lucid are now mapping differently than in the past, so we can
> no longer read our own files! Further, if any files are written by code
> produced by the new g++, they are corrupted.
>
> The problem is that doubles are now being mapped onto a boundary divisible
> by 8 rather than a boundary divisible by 4, meaning that offsets change and
> structs get bigger.
>
> I've attached a tar file showing the mapping on Jaunty, Karmic, and Lucid to
> show the change. This is a greatly simplified program that shows the
> problem, but it's happening in all of our C++ programs.
>
> HELP!
>
> System is Ubuntu 10.4 Lucid Lynx 64 bit.
>
> David Doucette
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux