home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / ada / 3744 < prev    next >
Encoding:
Text File  |  1992-12-17  |  1.5 KB  |  38 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!telesoft!garym
  3. From: garym@telesoft.com (Gary Morris @pulsar)
  4. Subject: Re: Novice Question on Record Representation
  5. Message-ID: <1992Dec17.182403.6353@telesoft.com>
  6. Organization: Alsys Group, San Diego, CA, USA
  7. References: <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com> <dnsurber.724602575@node_26400>
  8. Date: Thu, 17 Dec 1992 18:24:03 GMT
  9. Lines: 27
  10.  
  11. In <dnsurber.724602575@node_26400> dnsurber@lescsse.jsc.nasa.gov (Douglas N. Surber) writes:
  12. >    package P1 is
  13. >    type T is private;
  14. >    T_Size : constant := 32;
  15. >    private
  16. >    type T is new Integer;
  17. >    subtype Assertion is boolean range true .. true;
  18. >    a1 : constant Assertion := T_Size = T'Size;
  19. >    end P1;
  20.  
  21. >By using the Assertion, you assure that T_Size has the right value.  Yes,
  22. >you may have to tweak its value when you port, but you can't get a clean
  23. >compile with the wrong value so it is safe. 
  24.  
  25. Unfortunately, you can't rely on assertion like this.  The constant a1 is
  26. not used anywhere and an optimizing compiler could remove a1 and the
  27. expression used for its initial value (TSize = T'Size).  So the range check
  28. never occurs and no exception or compile time warning is generated.  This
  29. optimization is allowed by 11.6(7), when the only effect of a predefined
  30. operation is to raise an exception. 
  31.  
  32. --GaryM
  33. -- 
  34. Gary Morris                      Internet: garym@telesoft.com
  35. Ada Software Development         UUCP:     uunet!telesoft!garym
  36. Alsys West (TeleSoft)            Phone:    +1 619-457-2700
  37. San Diego, CA, USA               Fax:      +1 619-452-2117
  38.