[dmd-beta] dmd 1.062 and 2.047 beta

Andrei Alexandrescu andrei at erdani.com
Thu Aug 26 23:02:05 PDT 2010


Hello Rainer,

Catching up with my email backlog. Was there a fix on this issue?

Andrei

On 6/11/10 11:30 PDT, Rainer Schuetze wrote:
> Hi,
>
> I've tried to untangle the startsWith code, and here's the minimal test
> case I could come up with so far:
>
> ///////////////////////
> template binaryFunImpl(bool b)
> {
> template Body()
> {
> static assert(b);
> alias bool BodyType;
> }
> alias Body!().BodyType ReturnType; // line 9
> }
>
> uint startsWith(A)(A a) if (is(binaryFunImpl!(true ).ReturnType)) {
> return 1; }
> uint startsWith(A)(A a) if (is(binaryFunImpl!(false).ReturnType)) {
> return 0; } // line 13
>
> const uint var = startsWith(1);
> ///////////////////////
> dmd produces:
>
> test.d(6): Error: static assert (b) is false
> test.d(9): instantiated from here: Body!()
> test.d(13): instantiated from here: binaryFunImpl!(false)
>
> The error does not show up if var is not const. Also, dmd 2.032 to 2.045
> do not produce this error (2.046 fails), so it must be some compiler
> regression.
>
> As it seems, the compile time evaluation of startsWith uses the wrong
> specialization. Maybe, it is just not gagging error output?
>
> Any other ideas? I have not yet dived too deep into the template code of
> the compiler, but if nobody has a better clue (and time), I can give it
> a try.
>
> Rainer
>
> Andrei Alexandrescu wrote:
>> Thanks. It may take a while before I can tend to this. Could someone
>> else look at it?
>>
>> Andrei
>>
>> On 06/10/2010 12:53 PM, Rainer Schuetze wrote:
>>> Sorry, but it still doesn't work. The error occurs when the expression
>>> is evaluated at compile time, so the code added to the unittest does not
>>> cover the issue.
>>>
>>> Rainer
>>>
>>> Andrei Alexandrescu wrote:
>>>> Apologies. svn up should fix it, and bring some more goodies too :o).
>>>>
>>>> Andrei
>>>>
>>>> On 06/10/2010 10:14 AM, Don Clugston wrote:
>>>>> const bool fails = startsWith("ab", "a");
>>>> _______________________________________________
>>>> dmd-beta mailing list
>>>> dmd-beta at puremagic.com
>>>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>>>>
>>>
>>> _______________________________________________
>>> dmd-beta mailing list
>>> dmd-beta at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>>
>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta


More information about the dmd-beta mailing list