C++ Logo


Advanced search

Re: Remove infinite loop UB

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 9 May 2020 19:09:29 +0300
On Sat, 9 May 2020 at 18:38, connor horman via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>> In this case, your infinite loop is just a way to implement halting the
>> CPU. Most CPUs have specific instructions for that to reduce power
>> consumption. It is not unreasonable to implement it in assembler, even
>> if your CPU doesn't have such instructions.
> Not necessarily. The semantics differ between CPUs. As mentioned, I have STP on 6502 and 65816, but that prevents recieving NMIs as well as just simply progressing.
>> Theoretically, C/C++ could have a standard library function halt() that
>> would implement this, but thing is you would likely not have it in a
>> bare metal environment - as you said, you don't have a standard library.
> If that is what it appears I said, I appolgise. I do have a standard library, but its freestanding. Just above bare minimum, whatever can reasonably exist.
> Threading does not because there is no reasonable way to implement threads, nor mutual exclusion locks (et al.) because those would just be atomic spinlocks.

You need http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1494r0.html.
The committee hasn't discussed
it yet.

Received on 2020-05-09 11:12:43