Bug 18916 – ICE using Typedef and __LINE__

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-30T09:21:36Z
Last change time
2020-03-21T03:56:36Z
Keywords
pull
Assigned to
No Owner
Creator
Andrea Fontana

Comments

Comment #0 by trikkuz — 2018-05-30T09:21:36Z
This code: import std.typecons: Typedef; alias Line = Typedef!int; void foo(Line line = __LINE__) { } void main(){ foo(); } On DMD: __LINE__ Illegal instruction (core dumped) On LDC2: Error: Internal compiler error: Type Expression not implemented: __LINE__
Comment #1 by slavo5150 — 2018-05-30T10:40:40Z
Comment #2 by slavo5150 — 2018-06-09T09:53:27Z
Alternate test case that doesn't require Phobos. struct Line { int line; alias line this; this(int line) { this.line = line; } } void foo(Line line1 = __LINE__, int line2 = __LINE__, int line3 = int(__LINE__)) { assert(line1 == 12); assert(line2 == 21); assert(line3 == 12); } void main() { foo(); }
Comment #3 by slavo5150 — 2018-06-09T10:02:38Z
Same issue, but for __FILE__ --- module1.d module module1; struct File { string file; alias file this; this(string line) { this.file = file; } } void foo(File file1 = __FILE__, string file2 = __FILE__) { assert(file1 == "module1.d"); assert(file2 == "main.d"); } --- main.d import module1; void main() { foo(); }
Comment #4 by github-bugzilla — 2018-06-25T20:13:09Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3b3e97904dd844d2c7546c528a4cb6fec19fe106 Fix Issue 18916 - ICE using Typedef and __LINE__ https://github.com/dlang/dmd/commit/663625bce0f0f392e1ddb7078d216604c2b69f61 Merge pull request #8310 from JinShil/fix_18916 Fix Issue 18916 - ICE using Typedef and __LINE__