Microsoft.CodeCoverage.Console.exe don't remove C++ compile time code

julian lalu 21 Reputation points

I generate C++ code coverage with Microsoft.CodeCoverage.Console.exe.

I have the following code :

template<typename type_t>  
static constexpr type_t* allocate_array(const usize count) noexcept requires(is_not_same_v<type_t, void>) {  
    const usize allocation_size = count * sizeof(type_t);  
    if (std::is_constant_evaluated()) {  
        // Usage of std::allocator.allocate is allowed in constexpr dynamic allocation.   
        // The allocation should be freed with std::allocator<type_t>().deallocate in the same constexpr expression  
        return std::allocator<type_t>().allocate(count);  
    return reinterpret_cast<type_t*>(allocate(allocation_size));  

The branch if(std::is_constant_evaluated()) should not be covered but it is.
Codecov show me that the branch is evaluated to false but never to true... and this is normal but it should not be in coverage data.


llvm-cov gcov produce a far better coverage concerning constexpr evaluation.

Is there a way to remove this from the coverage report? I instrument it statically (Dynamic produce the same result), here is the config file

<?xml version="1.0" encoding="utf-8"?>  

Thank you for help!

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,632 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
337 questions
{count} votes