Bug 42412 - Illegal program accepted, RM 8.5.1(3), renames of classwide object
Summary: Illegal program accepted, RM 8.5.1(3), renames of classwide object
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.3.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-17 19:51 UTC by Ludovic Brenta
Modified: 2009-12-17 19:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.2
Known to fail: 4.3.4
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2009-12-17 19:51:51 UTC
package pak1 is
   type T1 is tagged null record;
   x1: T1;
   x2: T1'class := x1;
   x3: T1'class renames x1;  --ERROR: (detected)  T1'class vs T1
   x4: T1 renames x2;        --ERROR: (missed)    T1 vs T1'class
end pak1;

$ gnatmake pak1
gcc-4.3 -c pak1.ads
pak1.ads:5:25: expected type "T1'class" defined at line 2
pak1.ads:5:25: found type "T1" defined at line 2
gnatmake: "pak1.ads" compilation error

RM 8.5.1(3) says "The type of the object_name shall resolve to the
type determined by the subtype_mark."  T and T'class are considered
to be different types, and shouldn't match.  There is flexibility in
RM 8.6(23) for T'class to sometimes match T, but only when the rules
provide an "expected type".  But this flexibility doesn't apply when
the rules say "shall resolve to", as in this case, without giving an
expected type.  This subtle wording distinction can also be seen in
other places in the RM, such as 12.4(4) vs. 12.4(5).
Comment 1 Ludovic Brenta 2009-12-17 19:52:57 UTC
$ gnatmake pak1
gcc-4.4 -c pak1.ads
pak1.ads:5:25: expected type "T1'class" defined at line 2
pak1.ads:5:25: found type "T1" defined at line 2
pak1.ads:6:19: dynamically tagged expression not allowed
gnatmake: "pak1.ads" compilation error

So the bug is fixed in 4.4.