Thread overview
[Issue 15985] [REG2.068/2.069] Code doesn't link unless compiled with -debug
Feb 12, 2017
Vladimir Panteleev
Oct 08, 2017
Walter Bright
Oct 08, 2017
ag0aep6g@gmail.com
Dec 17, 2022
Iain Buclaw
Jan 29, 2023
Walter Bright
Jan 29, 2023
Iain Buclaw
Jan 31, 2023
Dlang Bot
Feb 08, 2023
Dlang Bot
May 02, 2016
https://issues.dlang.org/show_bug.cgi?id=15985

jiki@red.email.ne.jp changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jiki@red.email.ne.jp

--- Comment #1 from jiki@red.email.ne.jp ---
I confirmed this with dmd 2.068 and -m64 mode in Windows.

So -allinst option works.

--
February 12, 2017
https://issues.dlang.org/show_bug.cgi?id=15985

--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> ---
(In reply to Vladimir Panteleev from comment #0)
> Bisection attempts point towards master/stable branch merges (i.e. nothing
> useful).
> 
> It is probably a latent heisenbug triggered by other changes.

Sorry, that was wrong. (Digger could not bisect changes in the stable branch
properly)

Introduced in https://github.com/D-Programming-Language/dmd/pull/4944.

--
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=15985

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
Reduced it a bit to:

struct S()
{
    void delegate() d;
}

S!() f_Ds(U)()
{
    static if (is(U == struct))
        return S!()
            (
                {
                    foreach (i, field; U.init.tupleof)
                        f_Ds!(typeof(field))();
                }
            );

    else
        return f_Ds!(D)();
}

void f_E()
{
    auto f = S!()
        (
            {
                enum x = is(typeof(f_Ds!(D*)()));
                f_Ds!(D*)();
            }
        );
}

struct A
{
    D* d;
}

struct D
{
    A a;
    int b;
}

void main()
{
    f_E();
    f_Ds!(D*)();
}

--
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=15985

ag0aep6g@gmail.com changed:

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

--- Comment #4 from ag0aep6g@gmail.com ---
Reduced further:

----
void f()() { h!()(); }
void g()() { f!()(); }
void h()() { g!()(); }

enum x = is(typeof(g!()()));
alias my_h = h!();

void main() {}
----

And here's a variant that fails both with and without -debug:

----
void f()()
{
    g!()();
    h!()();
}

void g()() { f!()(); }
void h()() { f!()(); }

enum x = is(typeof(f!()()));
alias my_g = g!();

void main() {}
----

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15985

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #5 from Iain Buclaw <ibuclaw@gdcproject.org> ---
Original test was fixed by https://github.com/dlang/dmd/pull/13224

All other reductions still fail, and now fail *with* -debug ever since this change. https://github.com/dlang/dmd/pull/10968

--
January 29, 2023
https://issues.dlang.org/show_bug.cgi?id=15985

--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to ag0aep6g from comment #4)
> void f()()
> {
>     g!()();
>     h!()();
> }
> 
> void g()() { f!()(); }
> void h()() { f!()(); }
> 
> enum x = is(typeof(f!()()));
> alias my_g = g!();
> 
> void main() {}

Here's what I suspect is going on with this. Let's follow the semantic analsysis:

1. x is the first to get semantically analyzed. The typeof instantiates f!()

2. f!() instantiates g!() and h!()

3. my_g instantiates g!() directly

h!() is only instantiated indirectly, and since that instantiation happens during a typeof, it never gets marked as needing code to be generated for it.

--
January 29, 2023
https://issues.dlang.org/show_bug.cgi?id=15985

--- Comment #7 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Walter Bright from comment #6)
> 
> Here's what I suspect is going on with this. Let's follow the semantic analsysis:
> 

DMD's default behaviour is to eagerly prune templates it expects to be instantiated elsewhere. Undefined references are expected as a default behaviour.

If undefined errors still persist with -allinst, then that's a bug that needs fixing.

--
January 31, 2023
https://issues.dlang.org/show_bug.cgi?id=15985

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #14855 "fix Issue 15985 - [REG2.068/2.069] Code doesn't link unless compiled …" fixing this issue:

- fix Issue 15985 - [REG2.068/2.069] Code doesn't link unless compiled with -debug

https://github.com/dlang/dmd/pull/14855

--
February 08, 2023
https://issues.dlang.org/show_bug.cgi?id=15985

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14855 "fix Issue 15985 - [REG2.068/2.069] Code doesn't link unless compiled …" was merged into master:

- a476bc101e5c3172b8f18479fbf4557ba35a5a8a by Walter Bright:
  fix Issue 15985 - [REG2.068/2.069] Code doesn't link unless compiled with
-debug

https://github.com/dlang/dmd/pull/14855

--