------- Comment #2 from burnus at gcc dot gnu dot org 2007-04-27 13:16 ------- The problem is: if(0) { /* find index */ else { pos.1 = 0; } D.1356 = (int4) ((<unnamed-unsigned:32>) pos.1 + 1);
As C and the internal tree have array indexes starting at one, the final index has to be incremented by one. Thus "pos.1 = 0" is ok, but "+1" is only correct if one has an index. The simplest would be to have "pos.1 = -1". Then one needs to change trans-intrinsic.c's gfc_conv_intrinsic_minmaxloc: /* Initialize the position to zero, following Fortran 2003. We are free to do this because Fortran 95 allows the result of an entirely false mask to be processor dependent. */ gfc_add_modify_expr (&loop.pre, pos, gfc_index_zero_node); One should also check the library version of MIN/MAXLOC. -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords| |wrong-code Last reconfirmed|0000-00-00 00:00:00 |2007-04-27 13:16:34 date| | Summary|minloc/maxloc: wrong results|minloc/maxloc: wrong results |with empty array |with empty array (F2003 | |only) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31726