comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com (Robert Dewar)
Subject: Re: Discriminated record question
Date: 8 May 2002 19:56:55 -0700
Date: 2002-05-09T02:56:56+00:00	[thread overview]
Message-ID: <5ee5b646.0205081856.63e2639e@posting.google.com> (raw)
In-Reply-To: 2d87db3f.0205080210.34726bf3@posting.google.com

Mark.Doherty@uk.thalesgroup.com (Mark Doherty) wrote in message news:<2d87db3f.0205080210.34726bf3@posting.google.com>...

> Does the compiler have the freedom to raise it as a 
> Constraint_Error?

Highly dubious if you ask me. Report it as a bug.

Note that GNAT is so kind as to give you a warning if
you declare a type like this:

     1. package q is
     2.    type x (a : natural := 0) is record
     3.       s : string (1 .. a);
                               |
        >>> warning: creation of object of this 
            type may raise Storage_Error

     4.    end record;
     5.
     6.    ss : x;
           |
        >>> warning: Storage_Error will be raised at 
            at run-time

     7. end;

And sure enough, if you run this program, Storage_Error
will be raised. I really think raising Constraint_Error
is very dubious here. What is likely going on is that
the compiler is getting an overflow trying to compute
the maximum size of the object. As I said earlier, I 
would report it as a bug.

The warnings in GNAT are quite useful (checkout the -gnatw
flag for turning them on, at the very least -gnatwu should
be used pretty much all the time, the only reason it is not
the default is that making it the default would require the
modification of literally hundreds of tests in our test
suite :-)

Robert Dewar
Ada Core Technologies



  reply	other threads:[~2002-05-09  2:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-07 12:45 Discriminated record question Grein, Christoph
2002-05-07 19:18 ` Randy Brukardt
2002-05-09  2:52   ` Robert Dewar
2002-05-09 20:29     ` Randy Brukardt
2002-05-08 10:10 ` Mark Doherty
2002-05-09  2:56   ` Robert Dewar [this message]
2002-05-15 15:34     ` Mark Doherty
2002-05-15 18:12       ` Jeffrey Carter
  -- strict thread matches above, loose matches on Subject: below --
2002-05-16  5:03 Grein, Christoph
2002-05-07 12:17 Mark Doherty
2002-05-10  9:27 ` Emmanuel Briot
replies disabled

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