www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5950] New: Linker problem with AA.get()

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5950

           Summary: Linker problem with AA.get()
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This D2 code:


import std.stdio;
void main() {
    string[char] tab = ['e': "red", 'b': "blue"];
    string r;
    foreach (c; "aba") {
        // if (c in tab) r ~= tab[c]; // OK
        r ~= tab.get(c, ""); // ERR
    }
    writeln(r);
}


Gives me a linker error (DMD 2.053beta):

test.obj(test) 
Error 42: Symbol Undefined
_D6object28__T16AssociativeArrayTaTAyaZ16AssociativeArray3getMFaLAyaZAya

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 07 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5950


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm gmail.com
         OS/Version|Windows                     |All



Reproducible on Mac OS X. The missing symbol demangled is

immutable(char)[] object.AssociativeArray!(char,
immutable(char)[]).AssociativeArray.get(char, lazy immutable(char)[])

It is probably a regression since I can't reproduce it on ideone which uses
2.042, but it may simply be that the error doesn't manifest on Linux.

Reduced test case:
--------------------------
import std.stdio;   // <-- the import is necessary to trigger the bug!
void main() {
    string[char] tab;   // <-- must be a string[char]?
    tab.get('c', "");
}
--------------------------
Undefined symbols:
  "_D6object28__T16AssociativeArrayTaTAyaZ16AssociativeArray3getMFaLAyaZAya",
referenced from:
      __Dmain in x.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
--- errorlevel 1
--------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5950


Rainer Schuetze <r.sagitario gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario gmx.de



PDT ---
This seems to happen when there is an identical associative array declared in
an imported file, but that is not used to generate code from. Obviously dmd
believes it does not need to generate the template code again. Here's a reduced
test case:

-----
module test1;
int[string] map;

-----
module test2;
import test1;

int main()
{
    int[string] m;
    return m.keys.length;
}
-----

compiling this with "dmd test2.d" with the latest compiler from github yields

OPTLINK (R) for Win32  Release 8.00.11
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test2.obj(test2)
 Error 42: Symbol Undefined
_D6object28__T16AssociativeArrayTAyaTiZ16Associative
Array4keysMFNdZAAya
--- errorlevel 1

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