[GCC-XML] Bug with empty structure

Thomas Heller theller at python.net
Fri Jun 24 14:53:39 EDT 2005


Brad King <brad.king at kitware.com> writes:

> Thomas Heller wrote:
>> On this structure (I know it's silly, but it seems to appear in real
>> world header files)
>> typedef struct {
>> // OBSOLETE
>> } Y;
>> gccxml generates this:
>> <?xml version="1.0"?>
>> <GCC_XML cvs_revision="1.96">
>>   <Namespace id="_1" name="::" members="_3 " mangled="_Z2::"/>
>>   <Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std"/>
>>   <Struct id="_3" name="Y" context="_1" mangled="1Y" location="f0:3"
>>   file="f0" line="3" size="8" align="8" members="_4 _5 " bases=""/>
>>                      ^^^^^^^^
>> size="8" is a bug, isn't it?
>
> That's the size that GCC's parser is giving to the xml dump code.  C
> and C++ structures cannot be zero size because each object is supposed
> to have a unique address.  It is up to the compiler to choose a size
> for empty objects.  For some reason GCC is choosing size 8.

Is that really true?  gcc on my suse system, when compiling a program
which prints sizeof(Y) with the above definition and running it says
sizeof(Y) = 0, which is what I would expect.

Thomas




More information about the gccxml mailing list