[dmd-beta] dmd 1.058 and 2.043 beta

Don Clugston dclugston at googlemail.com
Thu Apr 8 01:15:37 PDT 2010


I think this might be a latent compiler bug which has just been
exposed. While evaluating a template constraint, if there's a bad
parameter in a function call, you get a function parameter of value
__error, which can never be resolved.
Here's a patch.

expression.c, line 6833.


    arguments = arrayExpressionSemantic(arguments, sc);

+    // If there was an error processing any argument,
+    // return an error without trying to resolve the function call.
+    if (arguments && arguments->dim)
+    {
+        for (int k = 0; k < arguments->dim; k++)
+        {   Expression *checkarg = (Expression *)arguments->data[k];
+            if (checkarg->op == TOKerror)
+                return checkarg;
+        }
+    }
    preFunctionParameters(loc, sc, arguments);


On 8 April 2010 05:29, Don Clugston <dclugston at googlemail.com> wrote:
> Further reduced test case:
>
> import std.typecons;
>
> struct V {
>      void * p[1];
> }
>
> alias Tuple!(V) crash;
>
> It seems to be related to the use of void *. (If you make V just
> struct V { void *p;}  it will still crash, but it's harder to debug).
>
>
>
> On 8 April 2010 00:32, Walter Bright <walter at digitalmars.com> wrote:
>> Hmm, nothing jumps out as obviously wrong there, though it clearly has
>> something to do with the .init. It should perhaps use .init[0] instead.
>>
>> Don Clugston wrote:
>>>>>
>>>>> (2) I'm working on tracking down the Phobos unittest stack overflow.
>>>>> It seems to be a regression. I've cut it down to this test case:
>>>>> ---
>>>>> import std.variant;
>>>>> import std.typecons;
>>>>>
>>>>> alias Tuple!(Variant) crash;
>>>>> ---
>>>>> There have been no relevant changes to Phobos. I'm still working on it.
>>>>>
>>>>
>>>> It compiled in DMD svn 421, and fails in svn 423. It's caused by the
>>>> ".init property for static arrays is now an array literal." change.
>>>>
>>>
>>> Here's the problem:
>>>
>>> conv.d,  line 260:
>>> /**
>>> For structs that do not define $(D toString), the conversion to string
>>> produces the list of fields.
>>>  */
>>> T to(T, S)(S s, in T left = S.stringof~"(", in T separator = ", ",
>>>        in T right = ")")
>>> if (is(S == struct) && isSomeString!(T) && !is(typeof(&S.init.toString)))
>>> {
>>>    Tuple!(FieldTypeTuple!(S)) * t = void;     // < ---------- Creates a
>>> Tuple
>>> ----------
>>> and Tuple contains toString, defined in typecons.d line 435:
>>>
>>>    string toString()
>>>    {
>>>        char[] result;
>>>        auto app = appender(&result);
>>>        app.put(toStringHeader);
>>>        foreach (i, Unused; noStrings!(T).Result)
>>>        {
>>>            static if (i > 0) result ~= toStringSeparator;
>>>            static if (is(typeof(to!string(field[i]))))
>>> <------------ this is calls to!()
>>>                app.put(to!string(field[i]));
>>> ------------
>>>
>>> And that's all I have time for. I think this should fixed before the
>>> release goes out -- it's a pretty nasty regression.
>>> _______________________________________________
>>> 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