Bug#416979: gnat-4.1: Illegal program not detected, RM 7.3(13), 4.9.1(1), nonstatic discriminants
Package: gnat-4.1
Version: 4.1.1-22
Severity: normal
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
-- System Information:
Debian Release: 4.0
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-amd64
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Versions of packages gnat-4.1 depends on:
ii gcc-4.1 4.1.1-21 The GNU C compiler
ii gnat-4.1-base 4.1.1-22 The GNU Compiler Collection (gnat
ii libc6 2.3.6.ds1-13 GNU C Library: Shared libraries
ii libc6-dev 2.3.6.ds1-13 GNU C Library: Development Librari
ii libgcc1 1:4.1.1-21 GCC support library
ii libgnat-4.1 4.1.1-22 Runtime library for GNU Ada applic
ii libgnatprj4.1 4.1.1-22 GNU Ada Project Manager
ii libgnatvsn4.1 4.1.1-22 GNU Ada compiler version library
gnat-4.1 recommends no packages.
-- no debconf information
Reply to: