www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14417] New: Wrong argument type for _d_cover_register2

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

          Issue ID: 14417
           Summary: Wrong argument type for _d_cover_register2
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: goejendaagh zonnet.nl

The function signature is:
extern (C) void _d_cover_register2(string filename, size_t[] valid, uint[]
data, ubyte minPercent)

'valid' should point to a boolean bit-array, where the bit-value indicates
whether the coverage line count is valid for the corresponding source line
number. The rest of the code assumes the slice type to be 'bit[]' (see the
precondition of BitArray::opIndex()), i.e. the slice points to the start of the
bit-array and the slice's length field is equal to the number of valid *bits*
in the array. The current type size_t[] indicates otherwise: the slice pointing
to the start of the bit-array and the length field being equal to the number of
valid size_ts (= valid bits divided by sizeof(size_t)).
This means the _d_cover_register2 function cannot be called from D code without
very ugly slice manipulation.

I see two possibilities of fixing this. I have no preference. 

1) Add a new _d_cover_register3 function, with the signature:
extern (C) void _d_cover_register3(string filename, size_t* valid_ptr, size_t
valid_len, uint[] data, ubyte minPercent). Deprecate _d_cover_register2.

2) Accept the current interface of _d_cover_register2, and fix calling code
(e.g. DMD), and fix the precondition of BitArray::opIndex().

I can work on a PR to fix this, but need advice on what course to take.
Thanks,
  Johan

--
Apr 06 2015