http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54633
Bug #: 54633 Summary: Issues with MINLOC/MINVAL (MAXLOC/MAXVAL) Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: diagnostic, ice-on-valid-code, wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Related to 54613, reported by James in the thread "Implicit" use of assignment(=)" at https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/5eAz5ns6AG0 Namely: https://groups.google.com/d/msg/comp.lang.fortran/5eAz5ns6AG0/G1uydcaGivkJ ISSUES: a) Wrong-code for minval4.f90? With gfortran 4.3, it gets rejected with: integer x(minval((/1/))) 1 Error: automatic object 'x' at (1) cannot have the SAVE attribute interestingly, NAG f95 accepts it unless I use explicitly "save :: x", then it rejects it with: Error: minval4.f90, line 7: Static array X cannot have variable bounds Thus, I am bit lost whether it is valid or not. b) ICE with minloc/minval (minval2.f90, minloc2.f90): integer x(sum(minloc((/1/)))) respectively: integer x(minval((/1/),mask=(/.TRUE./))) in gfc_trans_auto_array_allocation, at fortran/trans-array.c:5621 That's gcc_assert (!TREE_STATIC (decl)); and decl is the var_decl "x". The problem is that minloc/minval is not simplified to a constant. Other compilers do compile-time evaluate this. (Or they don't? Cf. (a).) c) minval3.f90: This program compiles in gfortran with -std=f95 but other compilers reject it with: MINVAL function is not permitted in an initialization expression integer, parameter :: m = minval((/1/)) I don't see ad hoc why the other compilers do accept in in (b) but not in (c).