CTFE Status
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Sat Dec 3 16:23:32 PST 2016
On Sunday, 4 December 2016 at 00:14:26 UTC, Stefan Koch wrote:
> On Saturday, 3 December 2016 at 23:30:58 UTC, Stefan Koch wrote:
>> Another bug in continue break handling has appeared.
>>
>> uint fn() {
>> for (;;)
>> {
>> if (true) break;
>> return 0;
>> }
>> return 1;
>> }
>>
>> static assert(fn());
>>
>> The above code is enough to trigger it.
>> Apparently the fixup jump for the break is never inserted.
>> I doubt that this is an off-by-one error again.
>>
>> It's going to be tricky.
>
> I figured out part of the reason for this bug.
> baically it's like this.
>
>
>> uint fn() {
>> for (;;)
> beginBlock:
> //causes and unconditonal jump (UC1) after the end of the block
>> {
>> if (true) break;
> // causes an unconditional jump(UC2) here to the end of the
> block
> UC2: goto endBlock;
>> return 0;
> endBlock:
> UC1: goto BeginBlock;
>> }
>> return 1;
>> }
This can be fixed by setting a state-flag whenever we are going
to process the body of an infinite loop.
If anyone tried at any point to break out of the loop we need to
introduce a conditional that becomes false and allows us to exit.
It's ugly but it will work regardless of nesting-level .... I
hope.
More information about the Digitalmars-d
mailing list