In GNAT 4.3.2, package bodies are able to raise uncatchable exceptions in begin .. end sections:
-- pkg1.ads package pkg1 is procedure init; end pkg1; -- pkg1.adb with Ada.Text_IO; package body pkg1 is procedure init is begin null; end init; begin Ada.Text_IO.Put_Line ("raising exception..."); raise Program_Error; end pkg1; -- main.adb with Ada.Text_IO; with pkg1; procedure main is begin null; exception when others => Ada.Text_IO.Put_Line ("caught something"); end main; $ gcc-4.3 -c pkg1.adb $ gcc-4.3 -c main.adb $ gnatbind main.ali $ gnatlink -o main main.ali $ ./main raising exception... raised PROGRAM_ERROR : pkg1.adb:14 explicit raise Note that the all-catching 'when others =>' exception handler at the end of main does NOT catch the Program_Error raised in the package body. I have tested on two different machines and obtained the same results. The problem does not occur on 4.2 (the exception can be caught cleanly). ------------------------------------------------------------------------ FreeBSD 6.4-RELEASE-p1 #0: Sun Dec 21 07:56:41 UTC 2008 r...@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386 Using built-in specs. Target: i386-portbld-freebsd6.4 Configured with: ./..//gcc-4.3.2/configure --enable-languages=c,ada --disable-nls --with-system-zlib --with-libiconv-prefix=/usr/local --program-suffix=43 --bindir=/usr/local/bin/gcc43 --libdir=/usr/local/lib/gcc-4.3.2 --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc43 --build=i386-portbld-freebsd6.4 Thread model: posix gcc version 4.3.2 (GCC) ------------------------------------------------------------------------ Linux blank 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686 GNU/Linux Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.3-3' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.3.3 (Debian 4.3.3-3) -- Summary: 4.3 - uncatchable exceptions when raised from package bodies at elaboration time. Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc at coreland dot ath dot cx GCC target triplet: i386-portbld-freebsd6.4 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39294