C++ Logo

std-discussion

Advanced search

Re: reading values as bytes without memcpu, from enum unsigned char?

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 10 Aug 2020 12:27:52 -0700
On Monday, 10 August 2020 12:00:10 PDT Ville Voutilainen wrote:
> > Ok, then we agree: this behaviour must not be UB. It needs to either be
> > implementation-defined or unspecified (but valid). I don't claim to know
> > the distinction between these two.
>
> Implementation-defined needs to be documented by the implementation,
> whereas unspecified
> does not need to be. Because it's unspecified. :P

Okay...

But what guarantees does unspecified provide? Can the application rely on this
behaviour being self-consistent?

Reading from uninitialised memory produces an unspecified value and trying to
use it in a comparison or return it is UB. But simply memcpy'ing uninitialised
memory is "ok".

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2020-08-10 14:31:41