[Issue 19545] __traits(compiles, X) false positive, further uses of X succeed but don't link

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 7 11:35:03 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19545

--- Comment #1 from John Colvin <john.loughran.colvin at gmail.com> ---
void main()
{
    pragma(msg, __traits(compiles, inputRangeObject(RegexMatch!string.init)));
    inputRangeObject(RegexMatch!string.init);
}

struct RegexMatch(T)
{
}

class InputRangeObject(R)
{
    this(R)
    {
    }

    R front()
    {
    }
}

InputRangeObject!R inputRangeObject(R)(R range)
{
    return new InputRangeObject!R(range);
}

I've tried bisecting to find when in the history this started to go wrong, but
it's hard (old dmds don't necessarily build on linux any more due to missing
gcc headers).

Here is the output from run.dlang.io, which suggests that there was a problem
existing before 2.060, because while there it doesn't mistakenly continue with
compilation it still reports `true` when it should say `false`:

Up to      2.060  : Failure with output:
-----
true
onlineapp.d(17): Error: function
onlineapp.InputRangeObject!(RegexMatch!(string)).InputRangeObject.front has no
return statement, but is expected to return a value of type RegexMatch!(string)
-----

           2.061  : Failure with output:
-----
true
onlineapp.o: In function
`_D9onlineapp68__T16inputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16inputRangeObjectFS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZC9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject':
/sandbox/onlineapp.d:24: undefined reference to
`_D9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject7__ClassZ'
/sandbox/onlineapp.d:24: undefined reference to
`_D9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject6__ctorMFS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZC9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject'
collect2: error: ld returned 1 exit status
--- errorlevel 1
-----

--


More information about the Digitalmars-d-bugs mailing list