Bug 17953 - Illegal program not detected, RM 3.9.2(9)
Summary: Illegal program not detected, RM 3.9.2(9)
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2004-10-12 18:50 UTC by Ludovic Brenta
Modified: 2015-12-05 10:43 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.0.0
Last reconfirmed: 2005-06-14 20:30:36


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2004-10-12 18:50:42 UTC
Debian Bug #276224:

--  If the expected type for an expression or name is some specific
--  tagged type, then the expression or name shall not be dynamically
--  tagged unless it is a controlling operand in a call on a
--  dispatching operation.
procedure Test_121 is
   package pak1 is
      type T1 is tagged null record;
      function f1 (x1: T1) return T1;
   end pak1;

   package body pak1 is
      function f1 (x1: T1) return T1 is
      begin
         return x1;
      end;
   end pak1;
   use pak1;

   type T2 is record
      a1: T1;
   end record;

   z0: T1'class := T1'(null record);
   z1: T1 := f1(z0);           -- ERROR: gnat correctly rejects
   z2: T2 := (a1 => f1(z0));   -- ERROR: gnat mistakenly allows
begin
   null;
end Test_121;


The output is:

test_121.adb:24:14: dynamically tagged expression not allowed
gnatmake: "test_121.adb" compilation error


The second error is not detected.
Comment 1 Andrew Pinski 2004-11-01 01:38:56 UTC
Confirmed.
Comment 2 Nicolas Boulenguez 2011-08-31 21:47:10 UTC
found 4.6.1
gnat reports an error when one is commented, but fails to report both.
Comment 3 Nicolas Boulenguez 2014-02-27 18:45:28 UTC
Found in 4.9-20140218
Comment 4 Eric Botcazou 2015-12-05 10:43:07 UTC
At least one error is always reported.