Consider the following minimal working example:
program p
type t
integer,allocatable::i
end type
type(t),allocatable::o
allocate(o)
deallocate(o)
end
This code was compiled with the Intel compiler (ifx 2024.2.1
) and flags -O2 -g
. Analyzing the executable with the Intel Inspector (inspxe-cl 2022.1
) and option --collect mi3
leads to an error:
P1: Error: Mismatched allocation/deallocation: New
P1.2: Error: Mismatched allocation/deallocation: New
a.out!0x8ac1: Error X2: Mismatched deallocation site: Function do_deallocate_all: Module ./a.out
./a.f90(6): Error X3: Allocation site: Function MAIN_: Module ./a.out
Changing the optimization flag for compilation to -O0
won't remove the deallocate
statement, and the error line starting with a.out!0x8ac1
will point to the line in the code with this statement instead:
./a.f90(7): Error X2: Mismatched deallocation site: Function MAIN_: Module ./a.out
Why does Intel Inspector consider this an error and how to fix it?
As already discussed in the comments to the question, this is a false positive of the Intel Inspector. As of 28.03.2024, this software is deprecated, so this issue will not be fixed. Intel recommends using the Sanitizers in the new versions of their compilers (e.g. -fsanitize=address
compilation flag) or Valgrind instead.
(I think it makes sense to keep this question in case someone stumbles across the same problem.)