On 10/7/2012 21:54, Tom Lane wrote:
> John Marino<draco@marino.st> writes:
>> Perhaps, you need to take a closer look at this. I guarantee that I
>> didn't do this for cosmetic reasons. GCC behavior changed with GCC 4.5
>> on this topic.
>
> You should report it as a bug in whatever distro you're using, because
> the behavior did *not* change anywhere else, and the code you say your
> compiler is rejecting is clearly legal per C standard. sizeof() is
> a compile-time constant.
>
> regards, tom lane
Tom, it's a stock gcc47.
It's not "sizeof" that is causing the problem.
One cause is bufpage.h,
#define SizeOfPageHeaderData (offsetof(PageHeaderData, pd_linp))
Offsetof is the offender.
Two more on htup.h:
#define MINIMAL_TUPLE_PADDING \
((offsetof(HeapTupleHeaderData, t_infomask2) - sizeof(uint32)) %
MAXIMUM_ALIGNOF)
#define MaxHeapTuplesPerPage \
((int) ((BLCKSZ - SizeOfPageHeaderData) / \
(MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData))))
Again, offsetof is the offender in both cases.
Are you 100% sure that offsetof is evaluated at compile time? Is this
not part of section 6.6 that I quoted earlier?
John