Skip to content

feat: enable strict compilation with maximum warnings as errors#13

Merged
Yaraslaut merged 6 commits into
masterfrom
improvement/strict-compilation
Jul 19, 2026
Merged

feat: enable strict compilation with maximum warnings as errors#13
Yaraslaut merged 6 commits into
masterfrom
improvement/strict-compilation

Conversation

@Yaraslaut

Copy link
Copy Markdown
Member

Summary

Adds MORPH_ENABLE_STRICT_COMPILATION option (default ON) that enables -Werror and ~60 additional warning flags across GCC, Clang, and MSVC. The CI gets this automatically; users can opt out with -DMORPH_ENABLE_STRICT_COMPILATION=OFF.

Changes

CMake infrastructure

  • New option MORPH_ENABLE_STRICT_COMPILATION (default ON, controlled by the option in case someone can't avoid warnings)
  • apply_warnings() now adds -Werror//WX and ~60 extra flags when strict mode is on
  • Moved -Wshadow, -Wconversion, -Wsign-conversion, -Wnull-dereference, -Wimplicit-fallthrough, and others from Clang-only to the common GNU/Clang baseline (GCC also supports them)

Warnings surfaced & fixed

  • switch-default: Added default: labels to 5 exhaustive switch statements
  • documentation: Removed empty @par Example paragraphs from doxygen comments (Clang -Wdocumentation)
  • @tparam/ on concepts: Clang's -Wdocumentation doesn't accept either on concepts — replaced with inline text
  • float-equality: Suppressed -Wfloat-equal in test files with intentional float comparisons
  • unused-member-function: Marked bridge-registered helper methods (fromJson/toJson) as [[maybe_unused]]
  • GCC -Wpedantic: Suppressed unsigned __int128 extension warning with pragma
  • GCC -Wuseless-cast: Removed redundant static_cast<uint64_t> on size_t
  • missing-designated-field-initializers: Added .roles = {} and .idempotencyKey = {} to initializers

Verification

  • Clang 22: clean build, 452/452 tests pass
  • GCC 16: clean build, 452/452 tests pass

- Add MORPH_ENABLE_STRICT_COMPILATION option (default ON)
- Enable -Werror and ~60 additional warning flags across GCC, Clang, MSVC
- Move shared diagnostics (Wshadow, -Wconversion, etc.) from Clang-only
  to the common GNU/Clang baseline
- Fix all warnings surfaced by the new flags:
  - Add missing default: labels in switch statements
  - Remove empty @Par Example paragraphs from doxygen docs
  - Suppress -Wfloat-equal in tests with intentional float comparisons
  - Mark bridge-registered helper methods as [[maybe_unused]]
  - Suppress GCC -Wpedantic on __int128 extension usage
  - Remove redundant static_cast on size_t in session_auth.hpp
  - Add missing .roles and .idempotencyKey fields in designated
    initializers
- datetime.hpp: rename 'text'→'str' to avoid -Wshadow on glz::text
- test_model.cpp: guard #pragma clang diagnostic with __clang__
- remote.hpp: noexcept on non-throwing lambda (-Wnoexcept)
- src/main.cpp: noexcept on non-throwing lambda (-Wnoexcept)
- backend.hpp: rename lambda capture h to avoid -Wshadow on structured binding
- compiler_options.cmake: drop -Wnoexcept (GCC 14 ICE on glaze templates + false positives on
  every std::function test lambda)
- offline_queue.hpp: suppress -Woverloaded-virtual on enqueue two-arg overload
- session_auth.hpp: explicit uint8_t cast for xor result (-Wconversion)
- test_subscription.cpp: rename lambda param to avoid -Wshadow
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

- compiler_options.cmake: drop -Warray-bounds=2 and -Wstringop-overflow=4
  (GCC 14 ICE on glaze templates); add clang-cl suppressions for
  covered-switch-default, documentation-unknown-command, padded,
  unique-object-duplication, c2y-extensions, missing-noreturn;
  add _CRT_SECURE_NO_WARNINGS for MSVC
- logger.hpp: remove backtick-wrapped escape sequences from doxygen
  comments to avoid clang -Wdocumentation-unknown-command
- ci.yml: pass -warnings-as-errors=* to clang-tidy via -extra-arg
  (clang-tidy-diff.py doesn't recognize the flag directly)
…r -Wall

- -Wrestrict triggers GCC 14 ICE on glaze template instantiations
- clang-cl -Wno-* suppressions must come after -Wall/-Wextra in the
  same compile_options call, otherwise -Wall re-enables the warnings
@Yaraslaut
Yaraslaut force-pushed the improvement/strict-compilation branch 5 times, most recently from e163228 to 9edc587 Compare July 19, 2026 09:02
- Install GCC 15 from ubuntu-toolchain-r/test PPA
- Install Clang 22 from apt.llvm.org
- Update all jobs: linux-compilers, linux-qt, valgrind, docs
@Yaraslaut
Yaraslaut force-pushed the improvement/strict-compilation branch from 9edc587 to a347641 Compare July 19, 2026 09:34
@Yaraslaut
Yaraslaut merged commit 10ecd06 into master Jul 19, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant