tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: strtonum(3) from OpenBSD?

At Fri, 3 Jul 2009 21:01:29 -0400 (EDT), der Mouse 
<mouse%Rodents-Montreal.ORG@localhost> wrote:
Subject: Re: strtonum(3) from OpenBSD?
> [Greg Woods]
> > (I now do understand a trap representation can trigger a trap
> > exception on any type of access, at least for non-auto variables that
> > is.)
> Why the carveout for auto?  Is it specifically forbidden to trap on
> reading (or modifying in a way that depends on the former value) an
> auto variable that has not yet been set to anything?

The best explanation I've been able to find (I've not tried to read
enough of the standard & rationale, to work it out for myself) is that
for automatic variables the implementation is free to give a default
value to un-initialized auto variables which is a trap representation.
In this case the first read access before a write could then raise an
exception (but the first write access will not raise an exception on an
auto variable even if it does contain a trap representation).

Alternatively since an un-initialized automatic variable could have any
garbage value before it is explicitly initialized it is possible that
such a garbage value may be a trap representation for the type used for
that variable.

I found an online copy of a relevant excerpt from Derek Jones' new book
that may help, or may just muddle things more :-)

His whole book seems to be available here:

I have yet to digest more than a few pages of it.  :-)

                                                Greg A. Woods
                                                Planix, Inc.

<>       +1 416 218-0099

Attachment: pgp8YWA3MPF26.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index