www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Code coverage and std.c.*

reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
Perhaps it's just me, but it seems like code coverage (-cov) and 
std.c.time (and friends) just don't see eye to eye.  Examples work best 
here.

Consider the following:

import std.c.time;

int main()
{
         printf("%d\n", time(null));

         return 0;
}

This compiles just fine with any of:

dmd -run test.d
dmd test.d && ./test

Which is exactly right.  But now try adding -cov (same affect with 
either of above, using -run for simplicity):

dmd -cov -run test.d

Instead of the expected:

gcc test.o -o test -lphobos -lpthread -lm
1140329968

I get:

test.o(.data+0x38): undefined reference to `_ModuleInfo_3std1c4time'
collect2: ld returned 1 exit status
--- errorlevel 1

However, if I use instead, let's say, std.date, it works fine.  But if 
it's std.c.anything, it gives the same general error.

Surely just changing an import from "std.date" to "std.c.stdio" should 
not stop the code coverage testing from working, should it?

Thanks,
-[Unknown]
Feb 18 2006
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
It looks as if this may have been a problem with the Linux version of 
phobos, as packaged.  On Windows, it compiles fine.

However, running the example I posted seems to give me an error (invalid 
UTF-8 sequence.)

C:\test>dmd -run dummy.d
1140768677

C:\test>dmd -cov -run dummy.d
1140768681
Error: 4invalid UTF-8 sequence

A blank dummy.lst file is created, but nothing appears within it.

Strange.

-[Unknown]


 Perhaps it's just me, but it seems like code coverage (-cov) and 
 std.c.time (and friends) just don't see eye to eye.  Examples work best 
 here.
 
 Consider the following:
 
 import std.c.time;
 
 int main()
 {
         printf("%d\n", time(null));
 
         return 0;
 }
 
 This compiles just fine with any of:
 
 dmd -run test.d
 dmd test.d && ./test
 
 Which is exactly right.  But now try adding -cov (same affect with 
 either of above, using -run for simplicity):
 
 dmd -cov -run test.d
 
 Instead of the expected:
 
 gcc test.o -o test -lphobos -lpthread -lm
 1140329968
 
 I get:
 
 test.o(.data+0x38): undefined reference to `_ModuleInfo_3std1c4time'
 collect2: ld returned 1 exit status
 --- errorlevel 1
 
 However, if I use instead, let's say, std.date, it works fine.  But if 
 it's std.c.anything, it gives the same general error.
 
 Surely just changing an import from "std.date" to "std.c.stdio" should 
 not stop the code coverage testing from working, should it?
 
 Thanks,
 -[Unknown]
Feb 24 2006