Hello,

Today I came across a strange bug while using D with `dmd`. I have still not been able to figure out under what conditions does it happen but it seems to be a DMD related bug to me. Here is a reproducible snippet of the code

```D
import std;

alias DG = void delegate();

class TType
{
}

class MyClass
{
this(TType t1, TType, double, double[2], double, double, DG, TType, TType, DG, DG, DG, double, double, double, double, double, ulong, bool)
    {
assert(t1 is null); // I am passing null so should be null!
        // NOTE: Seems to work in LDC but fails in DMD.
        writeln("No Bug!");
    }
}

void main()
{
    auto tt = new TType;

new MyClass(null, tt, 0, [0, 0], 0, 0, null, null, null, null, null, null,
            0, 0, 0, 0, 0, 0, false);
}
```
The code gives an assertion failure on the current versions of dmd (reproducible on [run.dlang.io](https://run.dlang.io) as well) and does not happen when using LDC. The bug seems to be sensitive to the number of arguments and their types making it reproducible only in very limited cases. I have tried my best to reduce it to minimum but still does require these many arguments. The end results seems to me like variables are shifted i.e. variable 1 gets value of variable 2 and so on, but don't have enough proof to support this.

I just wanted some help on the best way to avoid this bug in my code and maybe some clue on what causes the error in the first place and how should I go about reporting this.

Keivan

Reply via email to