Re: Uninitialized variable and the effects they have
- From: Wilhelm Spickermann <zulo.20.unbenutzbar@xxxxxxxxxxxxxxx>
- Date: Thu, 24 Nov 2005 17:33:22 +0100
Maciej Sobczak wrote:
> Is the behaviour of this program well-defined?
> I mean - I consider it to be well defined if it's guaranteed
> that exactly one of the branches is chosen and later statements
> are executed without any restrictions.
>
I don't think so. ("No", in the sense of your definition)
Referencing an uninitialized variable may raise Program_Error.
As it is a scalar, it is guaranteed to be a legal (= belonging to
the subtype) or illegal value of the type otherwise. You can use
I'VALID to find out which one it is and this usage of the
variable "I" will never raise Program_Error. But if you don't do
that, Constraint_Error may be raised when executing the
case-statement or sometime later. (provided there are any bit
patterns in the representation which do not belong to subtype
Integer).
So it is not "undefined behaviour" in the sense of "anything may
happen".
Wilhelm
.
- References:
- Uninitialized variable and the effects they have
- From: Maciej Sobczak
- Uninitialized variable and the effects they have
- Prev by Date: Re: Help installing GCC/GNAT 4.0.2
- Next by Date: Re: Filenames in Ada
- Previous by thread: Re: Uninitialized variable and the effects they have
- Index(es):