On 20/02/2021 07:30, JCampbell wrote:
> ...
> As a Fortran user, I am puzzled why "deallocate (p2, stat=ios) ; write (*,*) 'status = ',ios" is allowed to abort.
It's the underlying system call 'free' that behaves this way. BTW when I
build a particular package with gcc-4.8.5 I also face a, Linux specific,
invalid free (as caught by malloc_check_=1) not handled by this hack. So
there are known limitations.
> Steve Kargl appears to complain that your code is "invalid Fortran", but the question should be asked ;
His last comment was that a compiler can do anything, including what
the user expected.
So, such a bug fix may offer also covered protection from compiler bugs,
ie for PRs 93691 & 98433. It needs a little fine tuning for PR/97123 if
one doesn't compile with the option '-std=legacy'.
> "What is the point of "stat=ios" if not to report if there is a problem when deallocating a variable"?
> That a variable is no longer allocated is hardly "invalid Fortran", but the presence of stat= suggests some uncertainty about it's allocatable status and a way of testing and deallocating if already allocated.
>
> For the case of read (..., iostat=ios), tf there is a problem, the program does not crash but reports an error via ios.
> Why can't deallocate provide the same functionality ?
>
> Your question about OpenMP threads needs more information, especially if the variable is private or shared, where more care would be required and critical.
>
I had tried to code a function without local variables at all. I'm not
sure it's a bug if a thread reports a different address throughout it's
life-cycle, but I'm not confident that would be ok. So I restricted it.
Thank you