http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51208
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-18 16:03:04 UTC --- (In reply to comment #1) > (In reply to comment #0) > > allocate(i, stat=i) > > 1 > > Error: Stat-variable at (1) shall not be ALLOCATEd within > > the same ALLOCATE statement > > The above error is easy to produce, because gfortran > only has to check if an alloc-object is used as a > stat-variable. Well, you can make it also more complicated: allocate (a(1)%i, stat=a%(2-1)%i) Or extremely complicated: integer, pointer :: ptr allocate (ptr, stat=f()) contains function f() integer, pointer :: f f => ptr end function end (Recall that a pointer-function result is a variable in Fortran 2008.) > > However, for SOURCE= and MOLD= it does not work: > > Doing a check here requires a walk of the mold-expr > and the source-expr, which is of course much more > work Well, it is not. One can restrict one to the common case of expr->expr_type == EXPR_VARIABLE and just do the same as for STAT=: Checking whether the variable is the same. Will that catch all wrong usage? No, but it will catch the most common mistake of choosing the wrong variable. That's as illustrated above the same with STAT=. I am sure that Intel's compiler does not do anything more advanced - and it would have found the mistake I made in PR 51207.