https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90890
--- Comment #6 from Bharat Mahajan <bharat.mahajan at hotmail dot com> --- (In reply to Steve Kargl from comment #5) > You got lucky. You gave the compiler invalid code. It can do > anything with the code (including giving you a result that you > may expect). > Ok I see. I checked with ifort team and ifort also gives a warning in this case if appropriate option is used. And the correct way was to allocate 'a' to 0 size and then use it in order to avoid calls to 'allocated()' inside a loop. I didn't know that was an option in Fortran. Thanks for the clarifications!