Date: Tue, 27 Oct 2020 11:11:14 +0300
On 10/27/20 6:32 AM, Thiago Macieira via Std-Proposals wrote:
> On Monday, 26 October 2020 07:03:21 PDT Dusan Jovanovic (DBJ) via Std-
> Proposals wrote:
>> [[noreturn]]
>> inline void unreachable() {}
>
> This gives you a warning that a noreturn function does return in 3 out of the
> 4 major compilers: https://gcc.godbolt.org/z/h7sq5r
>
> Two of them don't optimise on the hint either.
>
I think the whole premise of that the code that has undefined behavior
does not execute is wrong. Undefined behavior means exactly that - if
the code runs, it's outcome is not known. I don't think the standard
requires compilers to take active steps to prevent such code from
running. Therefore, I believe, unreachable() should be implemented with
a compiler intrinsic.
> On Monday, 26 October 2020 07:03:21 PDT Dusan Jovanovic (DBJ) via Std-
> Proposals wrote:
>> [[noreturn]]
>> inline void unreachable() {}
>
> This gives you a warning that a noreturn function does return in 3 out of the
> 4 major compilers: https://gcc.godbolt.org/z/h7sq5r
>
> Two of them don't optimise on the hint either.
>
I think the whole premise of that the code that has undefined behavior
does not execute is wrong. Undefined behavior means exactly that - if
the code runs, it's outcome is not known. I don't think the standard
requires compilers to take active steps to prevent such code from
running. Therefore, I believe, unreachable() should be implemented with
a compiler intrinsic.
Received on 2020-10-27 03:11:20