C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] indeterminate value

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Sat, 20 Feb 2021 09:30:00 +0100
Jens,

on Fri, 19 Feb 2021 22:31:15 +0100 you (Jens Maurer via Liaison
<liaison_at_[hidden]>) wrote:

> So, for anything but "unsigned char", even looking at
> an uninitialized value is undefined behavior in C++
> (in C parlance, there might be a trap representation).

It is a bit more complicated in C, because of this weird `register`
rule and because of pointers:

  - an lvalue conversion of an uninitialized object that is never
    backed-up in storage (whatever that means) is undefined.

  - if the object has pointer type, lvalue conversion is also
    undefined.

And current practice seems to be that C implementors do a lot of weird
things when an uninitialized value is read other than byte-by-byte.

I think C would gain a lot of simplification and clarity, if we'd just
say that any lvalue conversion of an uninitialized object is
undefined, unless the read is through a character type.

Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2021-02-20 02:30:11