Thread overview
[Issue 19548] [REG 2.080] Missing reference to _D6object__T14__switch_errorZQrFNaNbNiNfAyamZv
Jan 06
Seb
Jan 06
Seb
Jan 06
Seb
Jul 16
Ali Ak
January 06
https://issues.dlang.org/show_bug.cgi?id=19548

Nicholas Wilson <iamthewilsonator@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iamthewilsonator@hotmail.co
                   |                            |m

--- Comment #1 from Nicholas Wilson <iamthewilsonator@hotmail.com> ---
Reduced a bit further

import std.stdio, std.bitmanip;

void main() {
        final switch (0) { }
        writef("");
}

--
January 06
https://issues.dlang.org/show_bug.cgi?id=19548

Seb <greeenify@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greeenify@gmail.com

--- Comment #2 from Seb <greeenify@gmail.com> ---
The linker error is different for me if I add -debug to the mix when compiling :D

---
foo.o:foo.d:_D76TypeInfo_S3std3uni__T13InversionListTSQBcQBb8GcPolicyZQBh__T9IntervalsTAkZQo6__initZ:
error: undefined reference to '_D6object__T10RTInfoImplVAmA2i32i8Z4datayG2m'
foo.o:foo.d:_D48TypeInfo_S3std3uni__T8CowArrayTSQwQu8GcPolicyZQz6__initZ:
error: undefined reference to '_D6object__T10RTInfoImplVAmA2i16i2Z4datayG2m'
---

Also as the behavior is different for `-checkaction=C`, I presume it runs into this:

https://github.com/dlang/dmd/blob/92408ea7b43f9636a5e5b0426d7c6ffd73576ca2/src/dmd/statementsem.d#L2596

Specifically CallExp needs to be a DotTemplateInstanceExp.

So this should be a good start:

---
diff --git a/src/dmd/statementsem.d b/src/dmd/statementsem.d index cd7ac9aca..3cb3f01c4 100644
--- a/src/dmd/statementsem.d
+++ b/src/dmd/statementsem.d
@@ -2602,16 +2602,16 @@ else
                 }
                 else
                 {
-                    Expression sl = new IdentifierExp(ss.loc, Id.empty);
-                    sl = new DotIdExp(ss.loc, sl, Id.object);
-                    sl = new DotIdExp(ss.loc, sl, Id.__switch_error);
+                    Expression objectId = new IdentifierExp(ss.loc,
Id.object);

                     Expressions* args = new Expressions();
                     args.push(new StringExp(ss.loc, cast(char*)
ss.loc.filename));
                     args.push(new IntegerExp(ss.loc.linnum));

-                    sl = new CallExp(ss.loc, sl, args);
-                    sl.expressionSemantic(sc);
+                    auto tiargs = new Objects();
+                    auto dt = new DotTemplateInstanceExp(ss.loc, objectId,
Id.__switch_error, tiargs);
+                    Expression sl = new CallExp(ss.loc, dt, args);
+                    sl = sl.expressionSemantic(sc);

                     s = new SwitchErrorStatement(ss.loc, sl);
                 }

---

However, it still doesn't trigger the instantiation.

--
January 06
https://issues.dlang.org/show_bug.cgi?id=19548

--- Comment #3 from Seb <greeenify@gmail.com> ---
PR: https://github.com/dlang/dmd/pull/9211

--
January 06
https://issues.dlang.org/show_bug.cgi?id=19548

--- Comment #4 from Seb <greeenify@gmail.com> ---
(In reply to Seb from comment #3)
> PR: https://github.com/dlang/dmd/pull/9211

Please ignore this PR. While I think it's on a good track, it still doesn't fix the instantiation problem and the test wasn't testing the linking.

--
July 16
https://issues.dlang.org/show_bug.cgi?id=19548

Ali Ak <ali.akhtarzada@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ali.akhtarzada@gmail.com

--- Comment #5 from Ali Ak <ali.akhtarzada@gmail.com> ---
Shouldn't this be marked as critical or something? You hit this issue quite randomly depending on which part of std you use. Can you mark something as a regression AND critical?

--