http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48831
Summary: check.c: Constant expression (PARAMETER array element) rejected as nonconstant Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: major Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Blocks: 32834 I know that this PR is a duplicate of some PR which I cannot find. http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/d0bd8bd1803b626e has the following program, which is rejected with: i3 = int(0, i2(1)) ! This line gives an error when compiling. 1 Error: 'kind' argument of 'int' intrinsic at (1) must be a constant In check.c, there is a simple expr_type == EXPR_CONSTANT check; however, using gfc_is_constant_expr() doesn't work either as PARAMETER (arrays) are not recognized as being constant. (EXPR_VARIABLE + FL_PARAMETER.) I think expr.c's check_init_expr might be better (it is currently static); however, I have the feeling all checks are wrong. Note: Fortran 95 distinguishes between initialization and constant expressions, in Fortran 2003 and Fortran 2008 they have been merged to a single type - called "initialization expressions" in Fortran 2003 and "constant expressions" in Fortran 2008. TODO: - Find out what F90's constant and init expressions mean - Make the less powerful call the more powerful, except for -std=f95 - Add checks for init/constant following the F95 pattern everywhere instead of using the half-baked EXPR_CONST or some made up test which check more, but only locally (e.g. const_expr + const array, as done in simplify.c) Note: The case below should unaffected by the const/init change and should be already valid Fortran 95. program p1 implicit none integer, parameter :: i1 = kind(0) integer, parameter :: i2(1) = [i1] integer(kind=i2(1)) :: i3 i3 = int(0, i1) print *, i3 i3 = int(0, i2(1)) ! This line gives an error when compiling. print *, i3 end program p1