This is the mail archive of the
mailing list for the GCC project.
[Fortran] Conquering the last Frontier ...
- To: gcc at gcc dot gnu dot org
- Subject: [Fortran] Conquering the last Frontier ...
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Sun, 21 Oct 2001 16:53:01 +0200
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
Consider this C program:
static float f;
f = 1.0;
and its Fortran counterpart:
a(1) = 1.0
Compiling the C program doesn't encounter any adverse effects:
toon@laptop:~/g77-bugs$ /usr/snp/bin/gcc large.c
However, the Fortran program elicits:
large.f: In program `aap':
Array `a' at (^) is too large to handle
This can be explained by the conditions the C, resp. Fortran front end,
employ to determine whether an array is "too large", i.e., won't be
The C front end uses the following tests (c-decl.c:4476ff):
if (tree_int_cst_sgn (size) < 0)
error ("size of array `%s' is negative", name); size =
/* Compute the maximum valid index, that is, size - 1.
Do the calculation in index_type, so that if it is
a variable the computations will be done in the
proper mode. */
itype = fold (build (MINUS_EXPR, index_type,
convert (index_type, size),
convert (index_type, size_one_node)));
/* If that overflowed, the array is too big.
??? While a size of INT_MAX+1 technically shouldn't
cause an overflow (because we subtract 1), the overflow
is recorded during the conversion to index_type, before
the subtraction. Handling this case seems like an
unnecessary complication. */
if (TREE_OVERFLOW (itype))
error ("size of array `%s' is too large", name); type =
Whereas the Fortran front end uses (com.c:2268ff):
if ((tree_int_cst_sgn (TYPE_SIZE (type)) < 0)
|| (!dummy && (((TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0))
|| TREE_OVERFLOW (TYPE_SIZE (type)))))
[ !dummy isn't very interesting in this case - it's used for dummy
arguments, whose size isn't know anyway. ]
Note the extra condition: TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0.
If I remove this, the Fortran code compiles as well.
So the 64K question is: Is this condition necessary, and if so, why -
and why isn't it present in the C front end ?
Thanks for any insight offered.
Toon Moene - mailto:email@example.com - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)