www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14043] New: Undefined reference error when compiling some

https://issues.dlang.org/show_bug.cgi?id=14043

          Issue ID: 14043
           Summary: Undefined reference error when compiling some
                    functions with -inline
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: GenericNPC gmail.com

When I try to call to std.stdio.File.rawRead with anything other than ubyte[]
and compile with -inline, dmd complains about undefined reference to
std.exception.errnoEnforce:

$ cat example.d
import std.stdio;
void main() {
    byte[] buffer;
    File file;
    file.rawRead(buffer);
}
$ dmd -inline example.d
example.o: In function `_D3std5stdio4File14__T7rawReadTgZ7rawReadMFAgZAg':
example.d:(.text._D3std5stdio4File14__T7rawReadTgZ7rawReadMFAgZAg+0x17d):
undefined reference to
`_D3std9exception102__T12errnoEnforceTbVAyaa34_2f7573722f696e636c7564652f646c616e672f646d642f7374642f737464696f2e64Vmi717Z12errnoEnforceFNfbLAyaZb'
collect2: error: ld returned 1 exit status
--- errorlevel 1


Note that this only happens when I use the -inline flag and when the argument
to rawRead is *not* ubyte[]. I don't think the problem is in Phobos, but in dmd
that cannot instantiate templates when inlining templated functions.

I've experienced this problem on dmd 2.066 and 2.066.1

--
Jan 25 2015