DMD CTFE Bug?

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Aug 17 09:57:10 PDT 2012


On 17-Aug-12 20:40, David wrote:
> Am 17.08.2012 18:36, schrieb Dmitry Olshansky:
>> On 17-Aug-12 20:27, David wrote:
>>> I have this code: http://dpaste.dzfl.pl/dbe2a07f
>>>
>>> It works perfectly fine, except for `t!(2, 10)` and `t!(1, 10)`:
>>>
>>> // Expected:
>>> [Vertex(-0.5, 0.5, 0.5, 0, 1, 0, 2, 10, 2, 10, 0, 0), Vertex(0.5, 0.5,
>>> 0.5, 0, 1, 0, 3, 10, 3, 10, 0, 0), Vertex(0.5,  0.5, -0.5, 0,  1, 0, 3,
>>> 9, 3, 9, 0, 0),
>>>   Vertex(-0.5, 0.5, 0.5, 0, 1, 0, 2, 10, 2, 10, 0, 0), Vertex(0.5, 0.5,
>>> -0.5, 0, 1, 0, 3, 9, 3, 9, 0, 0), Vertex(-0.5, 0.5, -0.5, 0, 1, 0, 2, 9,
>>> 2, 9, 0, 0)]
>>>
>>> // Actual result:
>>> [Vertex(-0.5, 0.5, 0.5, 0, 1, 0, 2, 10, 2, 10, 0, 0), Vertex(0.5, 0.5,
>>> 0.5, 0, 1, 0, 3, 10, 3, 10, 0, 0), Vertex(0.5, -0.5,  0.5, 0, -1, 0, 6,
>>> 3, 6, 3, 0, 0),
>>>   Vertex(-0.5, 0.5, 0.5, 0, 1, 0, 2, 10, 2, 10, 0, 0), Vertex(0.5, 0.5,
>>> -0.5, 0, 1, 0, 3, 9, 3, 9, 0, 0), Vertex(-0.5, 0.5, -0.5, 0, 1, 0, 2, 9,
>>> 2, 9, 0, 0)]
>>>
>>> If I change `enum` in line 117 to `auto` it produces the expected
>>> result.
>>>
>>> Any ideas why this happens?
>>
>> Bug. There is no excuse for compiler to get different result during CTFE.
>
> Great ...
>
>>> (Btw. I wasn't able produce a smaller testcase)
>> It's not thousands of lines either. But where does Vertex type comes
>> from?
>
> struct Vertex {
>      float x;
>      float y;
>      float z;
>      float nx;
>      float ny;
>      float nz;
>      byte u_terrain;
>      byte v_terrain;
>      byte u_mask;
>      byte v_mask;
>      float u_biome;
>      float v_biome;
> }
>

Well then I think all you have to do is to put together the complete 
sample and file it as CTFE bug here:
http://d.puremagic.com/issues/

-- 
Olshansky Dmitry


More information about the Digitalmars-d-learn mailing list