# CTest errors when collecting coverage results

**URL:** https://discourse.cmake.org/t/ctest-errors-when-collecting-coverage-results/15553
**Category:** Usage
**Created:** [March 11, 2026, 8:13pm UTC](https://discourse.cmake.org/t/ctest-errors-when-collecting-coverage-results/15553 "2026-03-11T20:13:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [March 11, 2026, 8:13pm UTC](https://discourse.cmake.org/t/ctest-errors-when-collecting-coverage-results/15553/1 "2026-03-11T20:13:05Z")

</div>

When running my CTest dashboard script with coverage flags enabled, it works perfectly for GCC. But for Clang builds, I get output such as:

```auto
Command produced error: D:/a/BenBot/BenBot/Builds/clang/libbenbot/resources/CMakeFiles/ben_bot_resources_internal.dir/Debug/__cmrc_ben_bot_resources_internal/intermediate/res/bench.epd.cpp.gcno:version 'B11*', prefer 'B52*'
Access violation
Access violation
Problem running coverage on file: D:/a/BenBot/BenBot/Builds/clang/libbenbot/resources/CMakeFiles/ben_bot_resources_internal.dir/Debug/__cmrc_ben_bot_resources_internal/intermediate/res/license_header.txt.cpp.gcda
Command produced error: D:/a/BenBot/BenBot/Builds/clang/libbenbot/resources/CMakeFiles/ben_bot_resources_internal.dir/Debug/__cmrc_ben_bot_resources_internal/intermediate/res/license_header.txt.cpp.gcno:version 'B11*', prefer 'B52*'
Access violation
Coverage command returned: 3 while processing: D:/a/BenBot/BenBot/Builds/clang/libbenbot/resources/CMakeFiles/ben_bot_resources_internal.dir/Debug/__cmrc_ben_bot_resources_internal/lib.cpp.gcda
Command produced error: 2
Coverage command returned: 3 while processing: D:/a/BenBot/BenBot/Builds/clang/libchess/CMakeFiles/libchess.dir/Debug/src/board/Distances.cpp.gcda
Command produced error: 2

```

The build itself produces no warnings/errors, and all tests pass, but CTest exits with code 32.

The coverage flags config is:

```auto
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    get_cmake_property (debug_configs DEBUG_CONFIGURATIONS)

    if (NOT debug_configs)
        set (debug_configs Debug)
    endif ()

    list (JOIN debug_configs "," debug_configs)

    set (config_debug "$<CONFIG:${debug_configs}>")

    add_compile_options ("$<${config_debug}:-g;-O0;--coverage>")
    add_link_options ("$<${config_debug}:--coverage>")

    if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
        link_libraries (gcov)
    endif ()
endif () 

```

An example build log is [here]([CI (benthevining) · benthevining/BenBot@270d93b · GitHub](https://github.com/benthevining/BenBot/actions/runs/22947455293/job/66603321995)), and the CDash dashboard is [here]([https://my.cdash.org/index.php?project=ben-bot](https://my.cdash.org/index.php?project=ben-bot)).

Is there something wrong with the coverage flags I’m using? Should I consider using a custom CTest script instead of just `ctest -D`, so that I can silence the spurious exit code?
