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.


-- 
           Summary: Ada: GCC accepts incorrect deferred constant declaration
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tero dot koskinen at iki dot fi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38882

Reply via email to