comp.lang.ada
 help / color / mirror / Atom feed
* Adding Things to Package System
@ 1999-02-18  0:00 Charles H. Sampson
  1999-02-18  0:00 ` dewar
  1999-02-23  0:00 ` Tucker Taft
  0 siblings, 2 replies; 10+ messages in thread
From: Charles H. Sampson @ 1999-02-18  0:00 UTC (permalink / raw)


     I've just come across what looks like an interesting bug in both 
the Green Hills and ObjectAda compilers.  While the bug itself is inter-
esting, the questions it raises are more so.

     The problem is illustrated by the following package:

     with System.Storage_elements;
     Package Address_arithmetic_bug is

     -- The following use type declaration makes
     
     --   function "+"(Left : Address; Right : Storage_offset)
     --     return Address;
     
     -- directly visible (among other things).
     
        use type System.Storage_elements.Storage_offset;
     
     -- The following use type declaration seems to cause the problem:
     
        use type System.Address;
     
        First_address : constant System.Address := 
         System.Storage_elements.To_address (16#10_000#);
         
        Second_address : constant System.Address := First_address + 1;
     
     end Address_arithmetic_bug;

     The compilers complain that the addition of an object of type Ad-
dress and an integer literal is ambiguous.  They do not give any details 
about which "+" operations are directly visible.  The code does compile 
o. k. under GNAT.

     I haven't received a reply to my bug report from Green Hills, but I 
suspect that a "+" operation has been added to package System that is 
made directly visible by the second use type clause.  If so, then we 
have an apparent conflict in the LRM.  13.7(36) clearly allows such ad-
ditions (although it discourages them), yet this is legal code that the 
compiler can't handle, in violation of 1.1.3(2).

     Am I correct in assuming that 1.1.3(2) rules?  If so, then how does 
that paragraph reconcile with 1.1.3(6), which appears to condone the ad-
dition?

     Offhand, it looks like any addition to System could give rise to 
similar problems.  For example, suppose an identifier is added to System 
and this identifier is also used in package Pkg.  Then, in the presence 
of use System and use Pkg clauses, that identifier would not be directly 
visible, although it would be for a compiler that uses the "minimal" 
package System.

				Charlie
--
******

     For an email response, my user name is "sampson" and my host
is "spawar.navy.mil".




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1999-02-28  0:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-18  0:00 Adding Things to Package System Charles H. Sampson
1999-02-18  0:00 ` dewar
1999-02-20  0:00   ` Charles H. Sampson
1999-02-20  0:00     ` Matthew Heaney
1999-02-21  0:00     ` dewar
1999-02-23  0:00 ` Tucker Taft
1999-02-26  0:00   ` Charles H. Sampson
1999-02-27  0:00     ` Tucker Taft
1999-02-28  0:00       ` dewar
1999-02-28  0:00     ` robert_dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox