comp.lang.ada
 help / color / mirror / Atom feed
* GNAT DOS vs. GNAT NT: Pragma Suppress?
@ 1997-03-20  0:00 Andrew Lynch
  1997-03-22  0:00 ` Robert Dewar
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Lynch @ 1997-03-20  0:00 UTC (permalink / raw)



We are having problems with a sample program that should show the user
what can happen when the Pragma Suppress is used.

Depending on the user's system we have either GNAT 3.07 for DOS or
GNAT 3.09 for Windows NT. Using the DOS compiler range checks can be
suppressed, but the NT compiler still causes exceptions to be raised.

The LRM 11.5(29) says that suppression of checks is not guaranteed,
but I would expect GNAT to handle this the same on various platforms.
GNAT on a Sun SPARC works the same as the DOS version, so why is the
NT version the odd one out?

Here is a shorter version of the code:
----------------->% snip %<--------------------
with Text_IO;
procedure Supprchk is
  N : Natural := 0;
  I : Integer := -3;
begin
  begin
    Text_IO.Put_Line( "Range_Check active");
    Text_IO.Put("Natural: ");
    N := I; -- exception raised
    Text_IO.Put_Line(Natural'Image(N));
  exception
    when Constraint_Error =>
      Text_IO.Put_Line("assignment error");
  end;
  declare
    pragma Suppress (Range_Check);
  begin
    Text_IO.Put_Line( "Range_Check turned off");
    Text_IO.Put("Natural: ");
    N := I; -- exception with NT, but not with DOS or SPARC
    Text_IO.Put_Line(Natural'Image(N));
  exception
    when Constraint_Error =>
      Text_IO.Put_Line("assignment error");
  end;
end Supprchk;
----------------->% snip %<--------------------

Using GNAT for DOS (under NT!) or GNAT for SPARC the output is

Range_Check active
Natural: assignment error
Range_Check turned off
Natural: -3

With GNAT for NT the output is

Range_Check active
Natural: assignment error
Range_Check turned off
Natural: assignment error

Is this deliberately different in the NT version, or should we maybe
file a bug report..? Could other people try this with the Windows NT
version of GNAT 3.09? In case it matters this was on a P120, running
the German Windows NT 4.00.1381

Thanks,
Andrew.

-- 
+----------------------------------------------------------------------+
| Andrew Lynch, MEng /        lynch@cci.de | Run, run, as fast as you  |
| CCI GmbH          /       alynch@iee.org | can. You can't catch me,  |
| Lohberg 10       /lynch@ug.cs.york.ac.uk | I'm the gingerbeard man!  |
| D-49716 Meppen  / Tel. ++49 5931 805-243 |       .sig by Anna Gramme |
+----------------------------------------------------------------------+




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

* Re: GNAT DOS vs. GNAT NT: Pragma Suppress?
  1997-03-20  0:00 GNAT DOS vs. GNAT NT: Pragma Suppress? Andrew Lynch
@ 1997-03-22  0:00 ` Robert Dewar
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1997-03-22  0:00 UTC (permalink / raw)



<<Is this deliberately different in the NT version, or should we maybe
file a bug report..? Could other people try this with the Windows NT
version of GNAT 3.09? In case it matters this was on a P120, running
the German Windows NT 4.00.1381>>

Don't file a bug report, there is no bug here. You wrote an erroneous
program (a program that violates a check that is suppressed is
erroneous). Erroneous programs can do anything they like, including
raise the exception anyway.

This demonstration program does not really demonstrate anything. If you
ran it and it deleted your system disk, you would no doubt be surprised,
but it still would not be a bug!

And no, there is no reason to expect erroneous programs to behave
the same on different versions of GNAT, or even on the same version
of GNAT from day to day.





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

end of thread, other threads:[~1997-03-22  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-20  0:00 GNAT DOS vs. GNAT NT: Pragma Suppress? Andrew Lynch
1997-03-22  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