https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108450

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Interestingly, it is resolved twice. First for:

(gdb) p gfc_debug_expr(e)
maxloc[((p:a) (mask = p:l))]

via
resolve_all_program_units → gfc_resolve → gfc_resolve → resolve_codes →
gfc_resolve_code → gfc_resolve_blocks → gfc_resolve_code → gfc_resolve_expr

And then via:
 ... → resolve_omp_atomic → gfc_resolve_expr

The problem is that in the latter case, the 'e' is now:

  maxloc[((p:a(FULL)) (mask = p:l) (.false.))]

and the unprefixed .false. seems to cause the problems.

The intrinsic uses:
   RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])
   RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])

During the first call to check_specific,

  maxloc[((p:a(FULL)) (mask = p:l))]

is turned into

  maxloc[((p:a(FULL)) ((arg not-present)) (mask = p:l) ((arg not-present))
((arg not-present)))]

via

4774      if (!sort_actual (specific->name, ap, specific->formal,
&expr->where))

The null-args are later removed via 'remove_nullargs (ap);'

 * * *

Thus, it looks as if resolving the RHS expression twice is wrong.

Reply via email to