g++ serious bug in Ubuntu Lucid Lynx
Christian Convey
christian.convey@gmail.com
Thu Jun 3 20:18:00 GMT 2010
>>> Are you sure that's a bug in the legalistic sense? IIRC, C and C++
>>> don't promise any particular memory layout for structs.
>>
>> They don't promise any particular memory layout, but gcc does promise
>> that it will not arbitrarily change the layout in new releases. If it
>> did, it would be impossible for code compiled by one version of gcc to
>> call a function defined by a different version of gcc while passing a
>> struct parameter.
>>
>> Ian
>
> I always thought that structure layout conventions are plarform-wide
> much like calling conventions. Otherwise, how can we link together
> code compiled by different compilers?
My impression is that it works more by luck and convention, than by
any particular promise. Of course it if didn't work out, people would
get fussy and the problem would get addressed one way or another.
It also may be one reason we don't see a lot of (or any?) structs show
up in operating system APIs. But that's just speculation on my part.
More information about the Gcc-help
mailing list