package pak1 is type T1(<>) is tagged limited private; private type T1(D: integer) is tagged limited null record; end pak1; with pak1; package pak2 is type T2 is new pak1.T1 with null record; -- ERROR: invalid constraint x1: T2 := (pak1.T1 with null record); -- line 5 end pak2; package pak1.pak3 is type T3 is new pak1.T1 with null record; -- ERROR: invalid constraint x2: T3 := (pak1.T1 with null record); end pak1.pak3; GCC 4.1: gnatmake -gnat05 pak2 gcc-4.1 -c -gnat05 pak2.ads +===========================GNAT BUG DETECTED==============================+ | 4.1.3 20070518 (prerelease) (Debian 4.1.2-8) (x86_64-pc-linux-gnu) | | Assert_Failure einfo.adb:813 | | Error detected at pak2.ads:5:4 | gnatmake -gnat05 pak1-pak3.ads gcc-4.1 -c -gnat05 pak1-pak3.ads pak1-pak3.ads:3:15: invalid constraint: type has no discriminant pak1-pak3.ads:4:14: no value supplied for discriminant "D" GCC 4.2: % gcc -c pak2.ads +===========================GNAT BUG DETECTED==============================+ | 4.2.2 (i686-unknown-linux-gnu) Assert_Failure einfo.adb:814 | | Error detected at pak2.ads:5:4 | % gcc -c pak1-pak3.ads pak1-pak3.ads:3:15: invalid constraint: type has no discriminant pak1-pak3.ads:4:14: no value supplied for discriminant "D" As can be seen, Pak1.Pak3 and Pak2 are identical but only Pak2 triggers the bug.
The initial test case was incorrect regarding the lines marked "ERROR". Here's a corrected version: package pak1 is type T1(<>) is tagged limited private; private type T1(D: integer) is tagged limited null record; end pak1; with pak1; package pak2 is type T2 is new pak1.T1 with null record; -- legal x1: T2 := (pak1.T1 with null record); -- ERROR, but accepted end pak2; package pak1.pak3 is type T3 is new pak1.T1 with null record; -- legal, but rejected x2: T3 := (pak1.T1 with null record); -- legal, but rejected end pak1.pak3; So in fact, Pak1.Pak3 also triggers a bug, albeit a different one from Pak2. I'll file it separately.
This is still present in 4.4.0 gcc -c pak2.ads +===========================GNAT BUG DETECTED==============================+ | 4.4.0 20090301 (experimental) (x86_64-unknown-linux-gnu) Assert_Failure einfo.adb:837| | Error detected at pak2.ads:5:4 ... pak2.ads pak1.ads /opt/gcc4/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/adainclude/a-unccon.ads (The assertion mentioned here to be on line 837 is the very same, in function Discriminant_Constraint.) A similar case triggering the same bug box, referring to the same function in einfo.adb: package T_Pack is type T (<>) is abstract tagged limited private; private type T (C: Character) is abstract tagged limited null record; end T_Pack; with T_Pack; package S_Pack is use T_Pack; type S is new T with private; function Create return S; private type S is new T with null record; end S_Pack; package body S_Pack is function Create return S is begin return S'(T with null record); end Create; end S_Pack; $ gnatmake s_pack.adb gcc -c s_pack.adb +===========================GNAT BUG DETECTED==============================+ | 4.4.0 20090301 (experimental) (x86_64-unknown-linux-gnu) Assert_Failure einfo.adb:837| | Error detected at s_pack.adb:5:7 ... Please include... s_pack.adb s_pack.ads t_pack.ads $ gcc -v Using built-in specs. Target: x86_64-pc-linux-gnu Configured with: /troy.d/gnatmail/release-gpl/build-troy/src/configure --prefix=/usr/gnat --target=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --enable-languages=c,ada --disable-nls --disable-libada --enable-checking=release --enable-threads=posix --disable-multilib Thread model: posix gcc version 4.1.3 20080522 for GNAT GPL 2008 (20080521) $ svn info Path: . URL: svn://gcc.gnu.org/svn/gcc/trunk Repository Root: svn://gcc.gnu.org/svn/gcc Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4 Revision: 144501 Node Kind: directory Schedule: normal Last Changed Author: gccadmin Last Changed Rev: 144501 Last Changed Date: 2009-03-01 01:16:55 +0100 (Sun, 01 Mar 2009)
pak2.ads:5:14: aggregate not available for type "T2" whose ancestor has unknown discriminants