This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/16095] Illegal program not detected, X'Access of wrong type



------- Comment #3 from ludovic at ludovic-brenta dot org  2008-11-17 22:32 -------
The bug was open at a time when the default mode of GCC was Ada 95; gcc -gnat95
still shows the error messages for line 11 if it is uncommented.

I think the bug is legitimate in Ada 95 mode (and probably in Ada 83 mode,
too).  The example violates 3.10.2(28) because the accessibility level of Y is
deeper than that of the anonymous access type of X.

Looking at the new rules for Ada 2005, I see that 3.10.2(28) has not changed. 
The AARM even says: "28.b/2 {AI95-00230-01} If A is an anonymous
access-to-object type of an access parameter access type, then the view can
never have a deeper accessibility level than A." In the present case, A is the
anonymous type of X and "the view" is Y, which does have a deeper accessibility
level than A.

Maybe I've missed an implicit type conversion rule, new to Ada 2005, that
permits converting Y'Access to the anonymous access type of X, thereby making
the program legal in -gnat05 mode.  But in -gnat95 mode, I'm pretty confident
the program is illegal.  The error messages for line 11 could be improved quite
a lot, though.

Anyway, I can't think of a situation where X = Y'Access (short of address
representation clauses or pragma Import/Export, where all bets are off anyway),
so I believe that even if the program is legal in Ada 2005, perhaps the
compiler should warn that "=" will always return False.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16095


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]