www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6744] New: Missing AA symbol with enum

reply d-bugmail puremagic.com writes:
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



---- 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: -------
Sep 29 2011
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Sep 29 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744




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: -------
Sep 30 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744


Brad Roberts <braddr puremagic.com> changed:

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



---
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: -------
Oct 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744




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: -------
Oct 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744


Brad Roberts <braddr puremagic.com> changed:

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



---
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: -------
Oct 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744




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: -------
Oct 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744


Shahid <govellius gmail.com> changed:

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



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: -------
Jul 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744





 ---- 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++"
 ];
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 17 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6744







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