Thread overview
[Issue 6744] New: Missing AA symbol with enum
Sep 29, 2011
Kenji Hara
Sep 29, 2011
Jonathan M Davis
Sep 30, 2011
Kenji Hara
Oct 23, 2011
Brad Roberts
Oct 23, 2011
Jonathan M Davis
Oct 23, 2011
Brad Roberts
Oct 24, 2011
Jonathan M Davis
Jul 10, 2012
Shahid
Feb 17, 2013
Kenji Hara
Feb 17, 2013
Kenji Hara
September 29, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6744

           Summary: Missing AA symbol with enum
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2011-09-29 15:59:07 PDT ---
---- test.d
import traits;
void formatValue()() { string[char] aa; aa.length; }
void main() { formatValue(); }

---- traits.d
enum LOOKUP_LINKAGE =
[
    'F': "D",
    'U': "C",
    'W': "Windows",
    'V': "Pascal",
    'R': "C++"
];

--- command line
dmd test.d

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 29, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6744


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-09-29 16:11:26 PDT ---
Yeah. I've been seeing various errors related to undefined symbols when using enums with AAs with the latest compiler, but I haven't been able to reduce them like this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 30, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6744



--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-09-30 07:25:02 PDT ---
This is not only the problem of AA, it is where template instantiation is belongs to.

---- test.d
import traits;
void func()(){ X!() x; auto n = x.length; }
void main(){ func(); assert(0); }

---- traits.d
struct X(){ int length(){ return 0; } }
enum x = X!()();

---- command line
dmd test.d

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

semantic() runs against the type of X!() at both line 2 in test and line 2 of
traits, but its instantiation belongs to only traits, because the semantic runs
 first in traits.
But the module traits never generate .obj, then the symbol ob X!().length will
be lost.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6744


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr@puremagic.com


--- Comment #3 from Brad Roberts <braddr@puremagic.com> 2011-10-23 14:28:53 PDT ---
What version of dmd ever built this code successfully?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6744



--- Comment #4 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-10-23 14:49:08 PDT ---
I have code with a similar error which compiled with 2.054 (or at least between the release of 2.054 and 2.055 - it compiled before, but it won't compile with 2.054 because it requires Phobos changes since 2.054 and it fails with 2.055 thanks to the compiler erroring out), but if this didn't compile with 2.054, then it's probably not quite the same bug, and I was premature in labeling it a regression. Unfortunately, I've failed to narrow down my code to a reasonable example for a bug report, so it's hard to be 100% certain that this is the same bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6744


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|regression                  |critical


--- Comment #5 from Brad Roberts <braddr@puremagic.com> 2011-10-23 14:55:10 PDT ---
I tried several points in time back to Jan 2010.  None of them built the example code.  Without a known working version, it's not a regression. Lowering to critical.

If you have code which went from working to not working and is valid code, please add it to this report or file a new one.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6744



--- Comment #6 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-10-23 17:03:03 PDT ---
Well, I'm definitely confused. I finally managed to reduce my code to a reasonably test case, but I can't find a version of the compiler where it worked. So, I don't know what happened. My test case is pretty similar to Kenji's though, so I expect that it's the same bug.

a.d
---
import b;

void main()
{
}

b.d
---
import std.exception;

enum E {a, b, c}
immutable int[E] aa;

shared static this()
{
    int[E] temp;
    temp[E.a] = 1;
    temp[E.b] = 2;
    temp[E.c] = 3;
    aa = assumeUnique(temp);
}


a.o: In function
`_D6object30__T16AssociativeArrayTE1b1ETiZ16AssociativeArray6rehashMFNdZHE1b1Ei':
b.d:(.text._D6object30__T16AssociativeArrayTE1b1ETiZ16AssociativeArray6rehashMFNdZHE1b1Ei+0x37):
undefined reference to `_D16TypeInfo_HE1b1Ei6__initZ'
a.o: In function
`_D6object31__T16AssociativeArrayTE1b1ETyiZ16AssociativeArray6rehashMFNdZHE1b1Eyi':
b.d:(.text._D6object31__T16AssociativeArrayTE1b1ETyiZ16AssociativeArray6rehashMFNdZHE1b1Eyi+0x37):
undefined reference to `_D17TypeInfo_HE1b1Eyi6__initZ'
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: -------
July 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6744


Shahid <govellius@gmail.com> changed:

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


--- Comment #7 from Shahid <govellius@gmail.com> 2012-07-10 09:45:07 PDT ---
void main()
{
    enum E { a=1, b=2 }

    // Fail at link
    // undefined reference to `_Dmain1E6__initZ'

    E[ string ] fail1 = [ "a":E.a, "b":E.b ];

    string[ E ] fail2 = [ E.a:"a", E.b:"b" ];

    // Works
    enum { c=3, d=4 }
    auto works1 = [ "c":c , "d":d  ];
    auto works2 = [  c:"c",  d:"d" ];
}
---

Bug does not happen if "enum E" is moved out of main to module scope.

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



--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-17 05:37:30 PST ---
(In reply to comment #0)
> ---- test.d
> import traits;
> void formatValue()() { string[char] aa; aa.length; }
> void main() { formatValue(); }
> 
> ---- traits.d
> enum LOOKUP_LINKAGE =
> [
>     'F': "D",
>     'U': "C",
>     'W': "Windows",
>     'V': "Pascal",
>     'R': "C++"
> ];

Now, the case in comment #0 is a dup of bug 8997, but more general case in comment #1 isn't.

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



--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-17 05:44:04 PST ---
(In reply to comment #8)
> Now, the case in comment #0 is a dup of bug 8997, but more general case in comment #1 isn't.

s/comment #1/comment #2/

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