Bug 34507 - Assert_Failure at einfo.adb:837 on illegal Ada 2005 program
Summary: Assert_Failure at einfo.adb:837 on illegal Ada 2005 program
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-17 09:27 UTC by Ludovic Brenta
Modified: 2015-12-05 12:03 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.2, 4.2.2, 4.4.0
Last reconfirmed: 2009-03-08 10:05:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2007-12-17 09:27:50 UTC
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.
Comment 1 Ludovic Brenta 2007-12-17 09:30:56 UTC
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.
Comment 2 Georg Bauhaus 2009-03-01 21:52:21 UTC
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)

Comment 3 Eric Botcazou 2015-12-05 12:03:37 UTC
pak2.ads:5:14: aggregate not available for type "T2" whose ancestor has unknown discriminants