I see this nasty miscompilation with the latest gcc from subversion, as well as with GNAT GPL 2009 and 2008 but not 2007.
$ gnatmake crash.adb gcc -c crash.adb gcc -c p64.adb gnatbind -x crash.ali gnatlink crash.ali $ ./crash raised STORAGE_ERROR : stack overflow (or erroneous memory access) -- chop here -- package P64 is type SA is access String; for SA'Size use Standard'Address_Size; S : SA; function P return Character; end; package body P64 is function Q (S : access constant String) return Character is begin if S /= null and then S'Length > 0 then return S (S'First); end if; return '*'; end; function P return Character is begin return Q (S); end P; end; with P64; procedure Crash is C : Character; begin C := P64.P; if C /= '*' then raise Program_Error; end if; end; -- Summary: Wrong handling of null for fat pointers forced thin by size clause Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: baldrick at free dot fr GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42253