Status of GCC-2.96-RH
Fergus Henderson
fjh@cs.mu.oz.au
Sun Apr 22 09:36:00 GMT 2001
On 19-Apr-2001, Joe Buck <jbuck@racerx.synopsys.com> wrote:
> > On Apr 19, 2001, JOSE LUIS RICARDO-CHAVEZ <ricardo@irsamc.ups-tlse.fr> wrote:
> >
> > > What is the status of GCC-2.96-RH?
> >
> > http://www.bero.org/gcc296.html
>
> Some of that web page is incorrect, at least for the version shipped with
> 7.0.
There are other errors in that web page as well.
| * The binary incompatibility issues are not as bad as some people
| and companies make you believe.
| First of all, they affect dynamically linked C++ code only. If you
| don't use C++, you aren't affected. If you use C++ and link
| statically, you aren't affected.
Binary incompatibilities issues can also cause problems if you use any
third-party C++ libraries, even if you link statically.
| Ignoring const qualifiers is valid (but not nice) C
It's not valid C.
| struct a {
| int a;
| int b;
| };
| [...]
| struct a *s=(struct a *)malloc(sizeof(struct a));
| memset(s + sizeof(int), 0, sizeof(int));
| assert(s.b==0);
|
|
| The compiler is free to rearrange structs. There is no guarantee
| whatsoever that s.b will be stored at &(s.a)+sizeof(int). fix the code
| - how to do this should be fairly obvious.
This is quite misleading. The compiler is not free to arbitrarily
rearrange structs. It can only insert padding, not reorder members.
The standard doesn't forbid the insertion of padding between two `int'
members in code like the above example, but I find it hard to imagine
any real compiler doing so. Certainly GNU C doesn't (not even 2.96-RH),
I'm pretty sure.
There may be other problems with the sample code -- e.g. it is missing a
cast --
| memset((char *)s + sizeof(int), 0, sizeof(int));
^^^^^^^^
but if those are fixed then I would expect it to work with gcc, and if it
doesn't then I'd say it was a bug in that version of gcc.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh > | -- the last words of T. S. Garp.
More information about the Gcc
mailing list