[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    [Bug ada/31417]  New: Illegal program not detected, RM 7.3(13), 4.9.1(1), nonstatic discriminants
From:       "ludovic at ludovic-brenta dot org" <gcc-bugzilla () gcc ! gnu ! org>
Date:       2007-03-31 22:07:14
Message-ID: bug-31417-286 () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]

In the program below, the full views (in the private part) of T2 and
T3 are both illegal because the value of the discriminant, x2, is not
static.  RM 7.3(13) states that the parent subtype of T2 and T3
(i.e. T1) must impose a statically matching constraint on the
discriminant, i.e. x1.  RM 4.9.1(1) states that a "statically matching
constraint" requires the value to be static.  Note that x3, despite
being a constant, is nonstatic because its value depends on x2 which
is nonstatic.

-- error not detected
package pak1 is
   -- RM 7.3(13), 4.9.1(1)
   -- check that discriminants statically match
   type T1(x1: integer) is tagged null record;
   x2: integer := 2;
   x3: constant integer := x2;
   type T2 is new T1 (x2) with private;
   type T3 is new T1 (x3) with private;
private
   type T2 is new T1 (x2) with null record;  --ERROR: nonstatic discriminant
   type T3 is new T1 (x3) with null record;  --ERROR: nonstatic discriminant
end pak1;

To reproduce:
gnatmake pak1.ads

Error messages expected:
pak1.ads:11:22: constraint in full view does not statically match ancestor's
discriminants
pak1.ads:12:22: constraint in full view does not statically match ancestor's
discriminants


-- 
           Summary: Illegal program not detected, RM 7.3(13), 4.9.1(1),
                    nonstatic discriminants
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ludovic at ludovic-brenta dot org


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic