Skip to content

Commit acdf688

Browse files
committed
fix(build): make GCC-specific warnings conditional and fix narrowing conversion
- Make -Wduplicated-cond, -Wduplicated-branches, and -Wlogical-op GCC-only since Clang doesn't support these flags - Fix narrowing conversion error in test_discrete_field.cpp by explicitly casting int to size_t in initializer list
1 parent 240d16c commit acdf688

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cmake/CompilerSettings.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wfatal-errors -Werror=format-security")
1414
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
1515
add_compile_options(
1616
-Wnull-dereference # Warn about potential null pointer dereferences
17+
)
18+
endif()
19+
20+
# GCC-specific warnings (not supported by Clang)
21+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
22+
add_compile_options(
1723
-Wduplicated-cond # Warn about duplicated conditions
1824
-Wduplicated-branches # Warn about duplicated branches
1925
-Wlogical-op # Warn about logical operator issues

tests/unit/core/test_discrete_field.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ TEST_CASE("pfc::interpolate() free function works correctly",
116116

117117
// Initialize: field[i] = i
118118
for (int i = 0; i < 5; i++) {
119-
field[{i}] = i;
119+
field[{static_cast<size_t>(i)}] = i;
120120
}
121121

122122
// Test rounding to nearest (std::round behavior)

0 commit comments

Comments
 (0)