GCC incorrectly accepts following code with deferred constant declaration: -- vstrings.ads -- gnatmake -c -gnatc vstrings.ads package VStrings is subtype VString_Size is Integer range 0 .. 160; type VString (Len : VString_Size := VString_Size'Last) is private; Empty_VString : constant VString (Len => 0); private type VString (Len : VString_Size := VString_Size'Last) is record Data : String (1 .. Len) := (others => ' '); end record; Empty_VString : constant VString := (Len => 0, Data => (others => ' ')); end VStrings; -- end For example Janus/Ada 3.1.2beta gives following error message: In File C:\koodi\ada\vstrings\VSTRINGS.ADS at line 13 -------------- 12: 13: Empty_VString : constant VString := (Len => 0, Data => (others => ' ')); -----------^ *ERROR* Deferred constant's type does not match forward definition (6.4.3) [RM 7.4(5)] According to RR Software technical support, Janus/Ada correctly rejects the code, because Empty_VString : constant VString := ...; does not have constraint at all and does not match its forward definition statically. Tested GCC versions were GCC 4.3.1 on OpenBSD/i386 and GCC 4.3.2 on Fedora 10/i386.
The error is still missing.
Fixed in GCC 13 and later: vstrings.ads:13:04: error: subtype does not statically match deferred declaration at line 6