[tlbuild] lcdf-typetools-2.85 doesn't compile with gcc-3.4.2 on old FreeBSD-5

Jonathan Kew jfkthame at googlemail.com
Mon Feb 7 16:08:01 CET 2011


On 7 Feb 2011, at 14:45, Peter Breitenlohner wrote:

> On Mon, 7 Feb 2011, Eddie Kohler wrote:
> 
>> Does the following work on both platforms?
>> 
>> ...
>> 	char real_data[0];	// but it is almost certainly more
>>   };
>> 
>>   enum {
>> 	MEMO_SPACE = sizeof(memo_t)
>>   };
>> 
>> Note different number of characters in real_data
> 
> Hi Eddie,
> 
> this works with both g++-3.4.6 (linux-x86) and g++-3.4.5 (mingw32 cross
> compilation on linux).  Because I vaguely remember some problems with
> size-zero arrays,

Right - "size-zero arrays" are not portable, and not supported by all compilers. (IIRC, they're illegal according to ISO C++, although some common compilers support them as an extension.)

> I have also tried
> 
>   ...
> 	char real_data[1];	// but it is almost certainly more
>   };
> 
>   enum {
> 	MEMO_SPACE = sizeof(memo_t) - 1
>   };
> 
> which succeeds as well (and I hope yields the same result, i.e., no padding
> at the end).

Relying on this also sounds like a recipe for trouble. I haven't checked the standard to see if this is explicitly specified, but my guess is that the result may be implementation-defined.

JK




More information about the tlbuild mailing list