http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-03-01 10:39:21 UTC --- (In reply to comment #3) > -std=f95 no longer generates the error that it should: > logical, parameter :: buf(3) = [(any(sc(i) ==nc), i = 1, 3)] > 1 > Error: transformational intrinsic 'any' at (1) is not permitted in an > initialization expression Ignoring the issue of [ ] vs. (/ /) which kicks in first: gfortran 4.4 diagnoses this, 4.5/4.6 do not. I think one reason that the error no longer is shown is the change with regards to constant vs. initialization expression. Fortran 2003 merged the two concepts to the name "initialization expressions" (which were renamed to "constant expressions" in F2008) - but in Fortran 95 not every constant expression was an initialization expression and some places mandated an initialization expression. F95 had: "7.1.6.1 Constant expression" "A constant expression is an expression in which each operation is intrinsic and each primary is [...] (5) A transformational intrinsic function reference where each argument is a constant expression," In the same section, "initialization expressions" are defined, which do not allows the transformational function NULL - and no other one. Thus, it might be that the missing diagnosis is a side effect of the F2003/F2008 support. (I think one needs to revamp that area as there are several bugs; unfortunately, it is a tedious task.) * * * Regarding the simplification, I tried the following patch, but that fails due to the above mentioned bug/mess with gfortran's implementation of init-expr vs. const-expr. In particular: The gfc_is_constant_expr(e) returns false as e->value.op.op1 is EXPR_VARIABLE (of attr.flavor FL_PARAMETER) and that function simply returns "0" if it encounters EXPR_VARIABLE. I sincerely believe the we do not want to touch the const/init-expr mess when the 4.6 release is imminent. --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -231,9 +231,17 @@ is_constant_array_expr (gfc_expr *e) if (e == NULL) return true; - if (e->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (e)) + if (!gfc_is_constant_expr (e)) return false; + if (e->expr_type != EXPR_ARRAY) + { + if (gfc_simplify_expr (e,1) != SUCCESS) + return false; + if (e->expr_type != EXPR_ARRAY) + return false; + } + for (c = gfc_constructor_first (e->value.constructor); c; c = gfc_constructor_next (c)) if (c->expr->expr_type != EXPR_CONSTANT