www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3252] New: undefined reference to package function called from an interface

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

           Summary: undefined reference to package function called from an
                    interface
           Product: D
           Version: 1.045
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Keywords: link-failure
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: diggory.hardy gmail.com


When attempting to call a function with package protection level from an
interface, I get an undefined reference error.


Code:

/** Compiler error - calling a package interface function.
 */
module packageFunc;

interface I {
    package void iPack();
}
class A : I {
    package void iPack() {}
}

void main () {
    A a = new A;
    I i = a;
    i.iPack;    // causes an undefined reference
    (cast(A) i).iPack;  // a workaround
}


The linker error:
# dmd packageFunc.d
packageFunc.o: In function `_Dmain':
packageFunc.d:(.text._Dmain+0x22): undefined reference to
`_D11packageFunc1I5iPackMFZv'
collect2: ld returned 1 exit status
--- errorlevel 1


Possibly similar to bug 2894.

This just bit me when including package protection to a lot of class functions
in order to implement invariant tests (where package protection is the only
applicable type of protection). I presume it's a bug; haven't tested if it's
also the case with dmd 2.0 or other compilers yet. Any idea if it would be
simple to fix?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3252


Alexey Ivanov <aifgi90 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aifgi90 gmail.com
         OS/Version|Linux                       |All


--- Comment #2 from Alexey Ivanov <aifgi90 gmail.com> 2010-01-24 09:46:54 PST
---
Same problem on windows

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3252



--- Comment #3 from Diggory <diggory.hardy gmail.com> 2010-01-24 11:49:07 PST
---
It shouldn't be platform specific anyway, but thanks for confirming it also
affects you.

Sorry, I guess this should have been linked to bug 3258.

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