Path: csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.std.c
Subject: Re: Does reading an uninitialized object have undefined behavior?
Date: Sat, 12 Aug 2023 17:00:40 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <86a5uv95g7.fsf@linuxsc.com>
References: <87zg3pq1ym.fsf@nosuchdomain.example.com> <87zg3pnuse.fsf@bsb.me.uk> <874jlxozzz.fsf@nosuchdomain.example.com> <87fs5hnipv.fsf@bsb.me.uk> <87a5vpnegz.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="40b94628daf1222a7895c880f36d7582"; logging-data="1635508"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MaWBsLkERspqwWeT5vlxjj0IFBePT1a0="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ytKDZl9PIlcus2vriIRjBUMze44= sha1:LAQCpRjwoKNHvKT4TYkZFNILVUY=
Xref: csiph.com comp.std.c:6529
Keith Thompson writes:
> I think the right way for C to permit NaT-like bits is, as Kaz
> suggested, to define "indeterminate value" in terms of provenance,
> not just the bits that make up its current representation. [...]
This idea is fundamentally wrong. NaT bits are associated with
particular areas of memory, which is to say objects. The point
of provenance is that non-viability is associated with /values/,
not with objects. Once an area of memory acquires an object
representation, the NaT bit or NaT bits for that memory are set
to zero, end of story. Note also that NaT bits are independent
of what type is used to access an object - if the NaT bit is set
then any access is illegal, no matter what type is used to do the
access. By contrast, provenance is used in situations where
non-viability is associated with values, not with objects. But
values are always type dependent; a pointer object that holds
a value that has been passed to free() is "indeterminate" when
accessed as a pointer type, but perfectly okay to access as an
unsigned char type. The two kinds of situations are essentially
different, and the theoretical models used to characterize the
rules in the two kinds of situations should therefore be
correspondingly essentially different.