Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Clang RelWithDebInfo builds with assertions enabled (missing -DNDEBUG)

Open Beginner friendly
#191 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cmake, cpp
Domain
build-system

Research direction

Start with cmake/compiler_flags/Clang.CXX.cmake and compare its CMAKE_CXX_FLAGS_RELWITHDEBINFO setting with cmake/compiler_flags/GNU.CXX.cmake. Configure a Clang RelWithDebInfo build and inspect build/*/compile_commands.json; done when the compile commands include -DNDEBUG. The coverage flags and warning-set inconsistencies are adjacent optional work, so confirm whether they are in scope.

Written by the indexing model from the issue text.

Description

bug performance

🤖 AI text below 🤖

What

cmake/compiler_flags/Clang.CXX.cmake:24-28 overwrites CMAKE_CXX_FLAGS_RELWITHDEBINFO with a flag
set that defines DEBUG and, crucially, does not define NDEBUG:

set(
  CMAKE_CXX_FLAGS_RELWITHDEBINFO
  "-O3 -g3 -DDEBUG -glldb -fno-limit-debug-info"
)

cmake/compiler_flags/GNU.CXX.cmake gets this right:

set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g3 -DNDEBUG")

Because the variable is overwritten rather than appended to, CMake's own default (which supplies
-DNDEBUG) is discarded.

Why this is a problem

Under Clang, RelWithDebInfo is an -O3 build with every assert live. Several sit on hot
paths:

  • cpp/monoprop/detail/operator/InvertedIndex.h, in fill_rows:
    assert(col.is_dense || std::ranges::is_sorted(col.set_rows));
    
    This runs for all 2 * NumModes columns on every fill_rows call, turning an O(new rows) append
    into O(columns × total rows) — so the cost per gate grows with the whole operator instead of with
    the newly inserted terms.
  • cpp/monoprop/detail/evolution/layer_build/Scan.h (the fused_scale_coeffs aliasing assert) and
    cpp/monoprop/detail/evolution/layer_build/Engine.h.

The flag set also carries -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer, i.e. this is
precisely the configuration someone reaches for when profiling. Any profile taken from a Clang
RelWithDebInfo build is currently measuring the assertions.

Suggested fix

Use -DNDEBUG in Clang's RelWithDebInfo, matching the GNU file:

set(
  CMAKE_CXX_FLAGS_RELWITHDEBINFO
  "-O3 -g3 -DNDEBUG -glldb -fno-limit-debug-info"
)

Two adjacent inconsistencies in the same file, worth folding in or splitting out as preferred:

  • Clang.CXX.cmake defines no CMAKE_CXX_FLAGS_COVERAGE, while GNU.CXX.cmake does
    (-O1 --coverage -g). .github/workflows/qa-analysis.yml sets
    SKBUILD_CMAKE_BUILD_TYPE: "Coverage", so a Clang leg of that job would build with no flags at all.
  • The Clang warning set is materially weaker than the GNU one: -Wextra, -Wconversion,
    -Wcast-align, -Wnon-virtual-dtor and -Wunused-parameter are GCC-only today.

Verification

Configure a Clang RelWithDebInfo tree and confirm NDEBUG appears in
build/*/compile_commands.json.


Found by a code-reading review of the repository at 29a8050. No build tree was available, so the
analysis is from source inspection and should be confirmed against a build.

Dominant language
C++
Stars
52
Forks
2
Avg merge
22h 23m
Merged PRs (30d)
36

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Algorithmiq/monoprop

All issues in Algorithmiq/monoprop

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.