D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17380 - Compiler segfaults on undefined symbol
Summary: Compiler segfaults on undefined symbol
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: ice
: 9327 (view as issue list)
Depends on:
Blocks:
 
Reported: 2017-05-07 11:04 UTC by kai
Modified: 2018-10-10 23:00 UTC (History)
4 users (show)

See Also:


Attachments
Source file demonstrating the bug. (7.04 KB, text/plain)
2017-05-07 11:04 UTC, kai
Details

Note You need to log in before you can comment on or make changes to this issue.
Description kai 2017-05-07 11:04:30 UTC
Created attachment 1645 [details]
Source file demonstrating the bug.

Compiling the attached source with dmd -unittest -main bug.d, dmd segfaults.
When line 88 is replaced by line 89 then it compiles and links.

The culprit is an undefined symbol:

        Uint128 opCast(T : Uint128)()
        {
            return ThisTypeDoesNotExistsAndCrahesTheCompiler(v);
        }

Changing to

        Uint128 opCast(T : Uint128)()
        {
            return Uint128(0);
        }

dmd does not crash.
Comment 1 ag0aep6g 2017-05-07 11:32:01 UTC
(In reply to kai from comment #0)
> Created attachment 1645 [details]
> Source file demonstrating the bug.

Reduced:

----
struct Int128
{
    Uint128 opCast()
    {
        return ThisTypeDoesNotExistsAndCrahesTheCompiler;
    }
    alias opCast this;
}

struct Uint128
{
    Int128 opCast() { return Int128.init; }
    alias opCast this;
}
----

Neither this reduction nor the original code compile for me with dmd 2.073.2. So this doesn't seem like a regression in 2.074 to me.
Comment 2 Walter Bright 2017-07-05 04:21:24 UTC
I don't think it is a regression, either.

https://github.com/dlang/dmd/pull/6969
Comment 3 github-bugzilla 2017-07-05 21:46:12 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/a583f97e3c99d91c499da6c3c3f22e810a5890d8
fix Issue 17380 - [REG 2.074.0] Compiler segfaults on undefined symbol

https://github.com/dlang/dmd/commit/e0223539bbdd6e0aef749ba93435c9144635d5f6
Merge pull request #6969 from WalterBright/fix17380

fix Issue 17380 - Compiler segfaults on undefined symbol
Comment 4 github-bugzilla 2017-08-07 13:17:22 UTC
Commits pushed to newCTFE at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/a583f97e3c99d91c499da6c3c3f22e810a5890d8
fix Issue 17380 - [REG 2.074.0] Compiler segfaults on undefined symbol

https://github.com/dlang/dmd/commit/e0223539bbdd6e0aef749ba93435c9144635d5f6
Merge pull request #6969 from WalterBright/fix17380
Comment 5 github-bugzilla 2017-08-16 13:23:25 UTC
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/a583f97e3c99d91c499da6c3c3f22e810a5890d8
fix Issue 17380 - [REG 2.074.0] Compiler segfaults on undefined symbol

https://github.com/dlang/dmd/commit/e0223539bbdd6e0aef749ba93435c9144635d5f6
Merge pull request #6969 from WalterBright/fix17380
Comment 6 Iain Buclaw 2018-10-10 23:00:19 UTC
*** Issue 6523 has been marked as a duplicate of this issue. ***
Comment 7 Iain Buclaw 2018-10-10 23:00:58 UTC
*** Issue 9327 has been marked as a duplicate of this issue. ***