C++ guys hate static_if?

Don turnyourkidsintocash at nospam.com
Fri Mar 15 03:50:46 PDT 2013


On Friday, 15 March 2013 at 06:51:15 UTC, Dmitry Olshansky wrote:
> 15-Mar-2013 10:47, Walter Bright пишет:
>> On 3/14/2013 11:36 PM, Dmitry Olshansky wrote:
>>> 15-Mar-2013 01:58, Andrei Alexandrescu пишет:
>>>> On 3/14/13 4:37 PM, Dmitry Olshansky wrote:
>>>>> Point taken. That doesn't detract us from:
>>>>> a) fixing issues with -cov
>>>>
>>>> Yes please (are there bugzilla entries etc)?
>>>
>>> template powerup(T) //usable as template mixin too
>>> {
>>>     //imagine more constraints
>>>     static if(size_t.sizeof == 4)
>>>         alias bleh = blah;
>>>     else
>>>         alias bleh = oldBlah;
>>>     //...
>>> }
>>>
>>> Now first mixin template don't get counted at all (even code 
>>> within).
>>> Then declarations are ignored and you'll never know which 
>>> ones were
>>> ever looked at.
>>
>> -cov only counts executable lines. The above are not 
>> executable - I
>> don't see any way to make them work with -cov.
>>
>
> The information can be trivially collected during semantic 
> analysis of declarations.
>
> How to merge this compile-time info with run-time one as in 
> -cov is a another question. I'd try outputting some table into 
> object file (special section etc.) and then -cov would use it 
> to mark non-executable code.

We need to do something like this. Without some kind of 
"instantiation coverage", it's practically impossible to be 
confident that your D templates are
correct. Actually I'm not certain that it needs to be the same 
file as -cov.
I mean, you might want to check that you have 100% template 
instantiation coverage, before you do your runtime tests.

It can be interesting to know that a line in a function template 
is instantiated 10 times, and run 3 times, whereas another line 
is run 857 times, but only instantiated once.


More information about the Digitalmars-d mailing list