proposed @noreturn attribute
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 9 09:19:18 PDT 2017
On Sunday, 9 July 2017 at 14:43:20 UTC, Andrei Alexandrescu wrote:
> On 07/09/2017 10:10 AM, Steven Schveighoffer wrote:
>> I haven't seen another solution other than out { assert(0); }
>
> Your own comment takes it to the recycle bin:
>
>> The one disadvantage, is that -release removes contracts. So
>> in this
>> particular case, the out contract should remain.
>
> That's already a hack on top of a hack.
An out contract should apply even when contracts are removed. The
compiler can treat it as not returning even if contracts are
removed. But the compiler could in this case leave the contract
in as a stop gap in case the function does return.
I fact it's fine if it doesn't. It will just be UB.
It's no more of a hack than leaving assert(0) in release code.
-Steve
More information about the Digitalmars-d
mailing list