http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51690
Bug #: 51690
Summary: Ada.Finalization with pointer field without explicit
initialization confuses compiler
Classification: Unclassified
Product: gcc
Version: 4.5.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 26192
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26192
26 line source file, self contained except for Ada.Text_Io which can be
eliminated.
Ada.Finalization plus access type fields that are not explicitly initialized in
the type declaration cause the compiler to complain that it has not seen the
body of its own internally generated support routines.
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.bug3/pb_code_main.adb
/home/geb/foo.gnat.bug3/pb_code_main.adb:10:05: warning: cannot call "F207b"
before body seen
/home/geb/foo.gnat.bug3/pb_code_main.adb:10:05: warning: Program_Error will be
raised at run time
gnatmake: "/home/geb/foo.gnat.bug3/pb_code_main.adb" compilation error
The number in "F207b" varies greatly as one works towards a cut down example.
The "b" in F207b is sometimes an "s". But this is always the form of the
complaint.
The attached file is about as minimal as I've been able to make it, 26 lines.
Compile it with the options above. Eliminate any type, an field, or change the
access type to something that is not an access type, and the problem goes away.
There is a workaround. Explicitly initialize the access type field to ":=
null;".
In a real program this means explicitly initializing all access type fields to
null but it seems to get the job done.