Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ if(PROJECT_IS_TOP_LEVEL)
sourcemeta_enable_simd()
endif()

# Enable the sanitizers before defining any target
if(SOURCEMETA_CORE_ADDRESS_SANITIZER)
sourcemeta_sanitizer(TYPE address)

@augmentcode augmentcode Bot Jul 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMakeLists.txt (diff line 62): because this is an if/elseif, if both SOURCEMETA_CORE_ADDRESS_SANITIZER and SOURCEMETA_CORE_UNDEFINED_SANITIZER are enabled, only the address sanitizer will be applied and the undefined sanitizer will be silently ignored.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

elseif(SOURCEMETA_CORE_UNDEFINED_SANITIZER)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Because this uses if/elseif, enabling both SOURCEMETA_CORE_ADDRESS_SANITIZER and SOURCEMETA_CORE_UNDEFINED_SANITIZER will silently apply only the address sanitizer while ignoring the undefined sanitizer. Consider either emitting a warning/error when both are set, or using separate if blocks (address and undefined sanitizers are compatible and can be combined in GCC/Clang).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At CMakeLists.txt, line 63:

<comment>Because this uses `if`/`elseif`, enabling both `SOURCEMETA_CORE_ADDRESS_SANITIZER` and `SOURCEMETA_CORE_UNDEFINED_SANITIZER` will silently apply only the address sanitizer while ignoring the undefined sanitizer. Consider either emitting a warning/error when both are set, or using separate `if` blocks (address and undefined sanitizers are compatible and can be combined in GCC/Clang).</comment>

<file context>
@@ -57,6 +57,13 @@ if(PROJECT_IS_TOP_LEVEL)
+# Enable the sanitizers before defining any target
+if(SOURCEMETA_CORE_ADDRESS_SANITIZER)
+  sourcemeta_sanitizer(TYPE address)
+elseif(SOURCEMETA_CORE_UNDEFINED_SANITIZER)
+  sourcemeta_sanitizer(TYPE undefined)
+endif()
</file context>

sourcemeta_sanitizer(TYPE undefined)
endif()

# TODO: Turn this into a re-usable utility CMake function
if(SOURCEMETA_CORE_INSTALL)
include(GNUInstallDirs)
Expand Down Expand Up @@ -226,12 +233,6 @@ if(SOURCEMETA_CORE_MARKDOWN)
add_subdirectory(src/core/markdown)
endif()

if(SOURCEMETA_CORE_ADDRESS_SANITIZER)
sourcemeta_sanitizer(TYPE address)
elseif(SOURCEMETA_CORE_UNDEFINED_SANITIZER)
sourcemeta_sanitizer(TYPE undefined)
endif()

if(SOURCEMETA_CORE_DOCS)
sourcemeta_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
Expand Down
Loading