http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51940
Bug #: 51940
Summary: Ada.Finalization of passed function return value
skipped if exception raised in routine
Classification: Unclassified
Product: gcc
Version: 4.5.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 26409
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26409
Sample failing program. Very simple code.
When a finalizable value is returned as a function result and passed to a
routine, if that routine terminates with an exception then the Finalization
routine is not called on the function result. The value thus escapes from
finalization control when it should not.
gcc -c -gnata -gnatE -fstack-check -gnatef -gnatf -gnatm50 -gnatn -gnato
-gnatwe -gnatwi -gnatwj -gnatwK -gnatwl -Wuninitialized -gnatVa
-pass-exit-codes -O -g -I- -gnatA /home/geb/foo.gnat.bug4/pb_code_main.adb
gnatbind -E -m50 -Sin -static -we -I- -x
/home/geb/foo.gnat.bug4/pb_code_main.ali
gnatlink /home/geb/foo.gnat.bug4/pb_code_main.ali -g -v -o
/home/geb/foo.gnat.bug4/pb_code_main
./pb_code_main
Initialize 3216937700 0
Value'Address 3216937700 0
---0---- 0
Adjust 3216937680 0
A'Address 3216937680 1
Finalize 3216937680 1
---1---- 0
Adjust 3216936828 0
X'Address 3216936828 1
Adjust 134716096 1
Finalize 3216936828 2
Adjust 3216937668 1
Finalize 134716096 2
B'Address 3216937668 1
Finalize 3216937668 1
---2---- 0
Adjust 3216936828 0
X'Address 3216936828 1
Adjust 134716096 1
Finalize 3216936828 2
Y'Address 134716096 1
**Notice lack of Finalization call on Y**
---3---- => 1
Adjust 3216936828 1
X'Address 3216936828 2
Adjust 134716096 2
Finalize 3216936828 3
Y'Address 134716096 2
**Notice lack of Finalization call on Y**
**Notice That both Y's have same address, so Y was deallocated or reused
without Finalization**
---4---- => 2
---5---- 2
Finalize 3216937700 2