compile/961203-1.c

Jim Wilson wilson@cygnus.com
Thu Oct 30 11:56:00 GMT 1997


Your patch is not correct.

You can't verify whether a size is negative by checking TREE_INT_CST_LOW.
Type sizes are stored as a pair of integers, and are negative only if
TREE_INT_CST_HIGH is negative.  Your patch will break 32 bit to 64 bit
cross compilation, because in such a case we need both integers to correctly
handle 64 bit type sizes, and it is easy for TREE_INT_CST_LOW to appear
to be negative when the entire value is not negative.  It isn't clear if
your patch will still if you check TREE_INT_CST_HIGH instead; I haven't
tried checking this.

Also, just because TREE_INT_CST_HIGH is negative does not mean that there
is a problem.  If you are cross compiling from a 32 bit host to a 64 bit
target, and you have a structure size which is very large, it could be
that TREE_INT_CST_HIGH will appear to be negative.  Gcc should not fail
for such a case.  Type sizes should be unsigned values, so ones that appear
to be negative should still be OK.

The proper way to handle this is to check whether a type size computation
resulted in an overflow.  In that case, and only in that case, gcc should fail.

We did try such a patch.  Unfortunately, this patch broke the Fortran front
end and had to be removed.  It turns out that the Fortran front end
intentionally generates an array large enough to cause a type size overflow.
We need to find a way to fix this problem, and then we can readd the type
size overflow error patch to fix the compile/961203-1.c problem.

Jim



More information about the Gcc mailing list