Sequential block statements can leak files
entity leakfiles is
end entity;
use std.textio.all;
architecture test of leakfiles is
begin
process is
begin
for i in 1 to 100000 loop
block is
file f : text open write_mode is "test.txt";
begin
null;
end block;
end loop;
wait;
end process;
end architecture;
The file F
is opened on each iteration of the loop and never closed. This behaviour is different to files declared in subprogram bodies which are implicitly closed when the subprogram returns and so cannot leak. That comes from the following paragraph in 5.2.2:
An implicit call to FILE_CLOSE exists in a subprogram body for every file object declared in the corresponding subprogram declarative part. Each such call associates a unique file object with the formal parameter F and is called whenever the corresponding subprogram completes its execution.
We should add similar text for sequential block statements. At present it is both inconsistent and error prone.
Suggestion:
An implicit call to FILE_CLOSE exists in a subprogram body or sequential block statement for every file object declared in the corresponding declarative part. Each such call associates a unique file object with the formal parameter F and is called whenever the corresponding subprogram or sequential block statement completes its execution.