C++ Logo


Advanced search

Re: [wg14/wg21 liaison] Semantics of angelic nondeterminism

From: Jₑₙₛ Gustedt <jens.gustedt_at_[hidden]>
Date: Fri, 12 Apr 2024 10:27:41 +0200
I am trying to wrap my head around this to know if this is a program
that should or should not be valid C. I didn't find any reason it
shouldn't. It is indeed non-deterministic, if my computations are
correct the return value is either `0` or `3`. But that's the deal if
you allow indeterminately sequenced evaluations in the language.

For C it is important that these kind of dealings are possible, not
because of the non-determinism, but because a storage instance that is
returned by `malloc` can have several effective types during its

If it is the case that C++ supposes that a `malloc`ed storage instance
has a fixed type from the start (we might just not know it yet) then
it is not modeling C's behavior correctly, and calling C functions
with `malloc`ed storage from C++ becomes hazardous. You may produce
non-value representations for the type that C++ is expecting, or even
introduce aliasing where the compiler wouldn't expect it.

In short, if a C function that is called from C++ changes the
effective type of the storage, behavior in C++ would be undefined, I


:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Université de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus ::
:: :::::::::::::::::::::::::::::::::::: ☎ +33 368854536 ::
:: https://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2024-04-12 08:27:46