https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100440
--- Comment #4 from David.Smith at lmu dot edu --- > Thanks for reduce this to a testcase. I don't see it attached > to this email or in bugzilla. gcc.gno.org may have stripped > the attachment (for some dumb reason). Feel free to send the >test case to me, and I make sure it gets attached to the bug > report. Ok, I will try attaching it as a zip file this time. ________________________________________ From: sgk at troutmask dot apl.washington.edu <gcc-bugzi...@gcc.gnu.org> Sent: Thursday, May 6, 2021 3:54 PM To: Smith, David Subject: [Bug fortran/100440] allocated() gives True for unallocated variable https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100440 --- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Thu, May 06, 2021 at 09:31:49PM +0000, David.Smith at lmu dot edu wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100440 > > --- Comment #2 from David.Smith at lmu dot edu --- > > With neither access to the actual code nor a reduced testcase, > > it will be virtually impossible to debug this problem. > > Right, I have enclosed a small program pulled out of my real application > that displays the error. Thanks for reduce this to a testcase. I don't see it attached to this email or in bugzilla. gcc.gno.org may have stripped the attachment (for some dumb reason). Feel free to send the test case to me, and I make sure it gets attached to the bug report. > > > Does the code run with the following compiler options: > > > -O0 -fno-frontend-optimize -fcheck=all > > Yes, it compiles and runs, giving the allocate error. > > > Does the code compile without warning if you use -Wall -Wextra? > > There are many warnings, and I think they may all be ignored for this > program: > > IUNKNO = -HUGE(I_TWO)/18 > Warning: Integer division truncated to constant ‘119304647’ > > (Yes, that is what we want) > > IF (MB%MP(2) /= MUNKNO .OR. MB%MP(3) /= 1) THEN > Warning: Inequality comparison for REAL(8) > > (This is a numerical analysis application -- it knows what it is > doing when it compares reals) > > KT1 = MWA%MP(J+1) > Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) > > (ditto) > > TYPE(MULTI), SAVE, DIMENSION(LMBERN) :: MBERN > Warning: Array ‘mbern’ at (1) is larger than limit set by > ‘-fmax-stack-var-size=’, > moved from stack to static storage. > > (That's fine here) > > INTEGER :: J,JMA,JMW,N1,N2 > Warning: Unused variable ‘jma’ declared > > (I removed most of the routines in the full program to make a small > version that gives the error. Also removed some test code that uses > these 'unused' variables) > > IF (KRESLT /= 0) THEN > Warning: ‘kreslt’ may be used uninitialized in this function > > (ditto) > > > > I have attached the file "allocate_error.f95". Output (without the warnings): > > > gfortran allocate_error.f95 -o allocate_error -Wall -Wextra -O0 > -fno-frontend-optimize -fcheck=all > $ allocate_error > > > > Sample 10. Eigenvalue from matrix powers. > > Iteration eigenvalue approximation > > 0 1.000000000000000000000000000000000000000000000000000000000 > 21 j= 1 allocated(FMMATMUL21_FM(J)%MFM%mp) = T > size(FMMATMUL21_FM(J)%MFM%mp) = 1 > allocate_error(29813,0x108292dc0) malloc: *** error for object > 0xb000000000000000: pointer being freed was not allocated > allocate_error(29813,0x108292dc0) malloc: *** set a breakpoint in > malloc_error_break to debug > > Program received signal SIGABRT: Process abort signal. > > Backtrace for this error: > #0 0x104c1ad3d > #1 0x104c1a16d > #2 0x7fff6f56042c > zsh: abort allocate_error The above malloc error suggests to me that you're possibly stepping off the end of an array. -fcheck=all should have caught that. :( -- You are receiving this mail because: You reported the bug.