Thread overview
[Issue 8023] New: (Regression git) Methods defined in external object files when template alias parameter is involved
May 03, 2012
Leandro Lucarella
May 03, 2012
Leandro Lucarella
May 04, 2012
Leandro Lucarella
May 04, 2012
Leandro Lucarella
May 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8023

           Summary: (Regression git) Methods defined in external object
                    files when template alias parameter is involved
           Product: D
           Version: D1
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: pull, wrong-code
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: leandro.lucarella@sociomantic.com
                CC: clugdbug@yahoo.com.au
        Depends on: 8016


--- Comment #0 from Leandro Lucarella <leandro.lucarella@sociomantic.com> 2012-05-03 03:31:28 PDT ---
+++ This issue was initially created as a clone of Issue #8016 +++

This looks like a reincarnation of bug 7745, but is different.

Testcase:

m1.d
---
module m1;

import m2;

private void t(alias Code)()
{
    return Code();
}

void f()
{
    t!( () { } )();
}
---

m2.d
---
module m2;
import m1;
---

dmd -c -inline -release -g m2.d && nm m2.o | grep '_D2m11fFZv$' 00000000 T _D2m11fFZv

Which means that _D2m11fFZv (AKA m1.f()) is included in the text
(code) section of m2.o, but it shouldn't, it should only be in m1.d (which I
didn't even compile), otherwise when linking both m1.o and m2.o you'll get a
"multiple definition" error. Symbol _D2m11fFZv should be not present at all in
that object file.

Please note that the compiler flags -inline -release has to be used to reproduce the bug, removing either makes it go away. -O is irrelevant. Confirmed in both 32 and 64 bits.

This regression was introduced by commit "fix Issue 2962 - ICE(glue.c) or bad
codegen passing variable as template value parameter":
D1: https://github.com/D-Programming-Language/dmd/commit/d5a33a1

This pull request (for D2, expect a small conflict when merging), fixes the
problem:
https://github.com/D-Programming-Language/dmd/pull/920

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8023



--- Comment #1 from Leandro Lucarella <leandro.lucarella@sociomantic.com> 2012-05-03 04:22:06 PDT ---
Add a test case for this bug. Even when is not reproducible in D2 right now, maybe is a good idea to have the test case anyway so it doesn't fail in the future as D1 does now.

https://github.com/D-Programming-Language/dmd/pull/922

This includes also this test case, which is also a regression and it's fixed by the pull request. This testcase doesn't need -inline -release to be reproduced though!

m1.d
---
module m1;

import m2;

private void t(alias Code)()
{
    return Code();
}

void f()
{
    t!( () { } )();
}

bool forceSemantic()
{
    f();
    return true;
}

static assert(forceSemantic());
---

m2.d
---
module m2;
import m1;
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8023



--- Comment #2 from github-bugzilla@puremagic.com 2012-05-03 13:27:36 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/704977f1decd9b2d589bd40431f5d001b0aa6d4e Add test cases for bug 8023

https://github.com/D-Programming-Language/dmd/commit/c947c201cd59ecb0db618acefe4a528a2d6ee1d5 Merge pull request #922 from llucax/test8023

Add test case for bug 8023

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8023



--- Comment #3 from Leandro Lucarella <leandro.lucarella@sociomantic.com> 2012-05-04 01:38:44 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d420faebda45eb27596697594a61ecd2a6d3b3d7
Fix issue 8016 Regression Methods defined in external object files when
template alias parameter is involved

Make the fix for bug 2962 a bit less aggressive. Still passes all test cases for 2962.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8023


Leandro Lucarella <leandro.lucarella@sociomantic.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8023



--- Comment #4 from github-bugzilla@puremagic.com 2012-05-17 09:21:34 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7206fc459027864dfb1990fc3b576c5ff8d08e68 Add testcase for bug 8023

https://github.com/D-Programming-Language/dmd/commit/98d21c4a910055e7b6a1471bb215a6a4955ea7fd Merge pull request #923 from llucax/test8023

Add test cases for bug 8023

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------