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.
Confirmed.
found 4.6.1 gnat reports an error when one is commented, but fails to report both.
Found in 4.9-20140218
At least one error is always reported.