Skip to content

Commit 2859981

Browse files
authored
fixed #478 - fail builds in CI on compiler warnings (#479)
1 parent 7bca11f commit 2859981

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ jobs:
4747
python3 -m pip install pytest
4848
4949
- name: make simplecpp
50-
run: make -j$(nproc)
50+
run: make -j$(nproc) CXXOPTS="-Werror"
5151

5252
- name: make test
53-
run: make -j$(nproc) test
53+
run: make -j$(nproc) test CXXOPTS="-Werror"
5454

5555
- name: selfcheck
5656
run: |
5757
make -j$(nproc) selfcheck
5858
5959
- name: Run CMake
6060
run: |
61-
cmake -S . -B cmake.output
61+
cmake -S . -B cmake.output -DCMAKE_COMPILE_WARNING_AS_ERROR=On
6262
6363
- name: CMake simplecpp
6464
run: |
@@ -81,27 +81,27 @@ jobs:
8181
if: matrix.os == 'ubuntu-24.04' && matrix.compiler == 'g++'
8282
run: |
8383
make clean
84-
make -j$(nproc) test selfcheck CXXOPTS="-g3 -D_GLIBCXX_DEBUG"
84+
make -j$(nproc) test selfcheck CXXOPTS="-Werror -g3 -D_GLIBCXX_DEBUG"
8585
8686
- name: Run with libc++ hardening mode
8787
if: matrix.os == 'ubuntu-24.04' && matrix.compiler == 'clang++'
8888
run: |
8989
make clean
90-
make -j$(nproc) test selfcheck CXXOPTS="-stdlib=libc++ -g3 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" LDOPTS="-lc++"
90+
make -j$(nproc) test selfcheck CXXOPTS="-Werror -stdlib=libc++ -g3 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" LDOPTS="-lc++"
9191
9292
- name: Run AddressSanitizer
9393
if: matrix.os == 'ubuntu-24.04'
9494
run: |
9595
make clean
96-
make -j$(nproc) test selfcheck CXXOPTS="-O2 -g3 -fsanitize=address" LDOPTS="-fsanitize=address"
96+
make -j$(nproc) test selfcheck CXXOPTS="-Werror -O2 -g3 -fsanitize=address" LDOPTS="-fsanitize=address"
9797
env:
9898
ASAN_OPTIONS: detect_stack_use_after_return=1
9999

100100
- name: Run UndefinedBehaviorSanitizer
101101
if: matrix.os == 'ubuntu-24.04'
102102
run: |
103103
make clean
104-
make -j$(nproc) test selfcheck CXXOPTS="-O2 -g3 -fsanitize=undefined -fno-sanitize=signed-integer-overflow" LDOPTS="-fsanitize=undefined -fno-sanitize=signed-integer-overflow"
104+
make -j$(nproc) test selfcheck CXXOPTS="-Werror -O2 -g3 -fsanitize=undefined -fno-sanitize=signed-integer-overflow" LDOPTS="-fsanitize=undefined -fno-sanitize=signed-integer-overflow"
105105
env:
106106
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:report_error_type=1
107107

@@ -110,4 +110,4 @@ jobs:
110110
if: false && matrix.os == 'ubuntu-24.04' && matrix.compiler == 'clang++'
111111
run: |
112112
make clean
113-
make -j$(nproc) test selfcheck CXXOPTS="-O2 -g3 -stdlib=libc++ -fsanitize=memory" LDOPTS="-lc++ -fsanitize=memory"
113+
make -j$(nproc) test selfcheck CXXOPTS="-Werror -O2 -g3 -stdlib=libc++ -fsanitize=memory" LDOPTS="-lc++ -fsanitize=memory"

.github/workflows/CI-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
4141
- name: Run CMake
4242
run: |
43-
cmake -G "Visual Studio 17 2022" -A x64 . || exit /b !errorlevel!
43+
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_COMPILE_WARNING_AS_ERROR=On . || exit /b !errorlevel!
4444
4545
- name: Build
4646
run: |

.github/workflows/clang-tidy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
3131
- name: Prepare CMake
3232
run: |
33-
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
33+
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
3434
env:
3535
CXX: clang-20
3636

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
4040
add_compile_options_safe(-Wuseless-cast)
4141
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
4242
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
43+
# TODO: bump warning level
44+
#add_compile_options(/W4) # Warning Level
45+
# TODO: enable warning
46+
add_compile_options(/wd4267) # warning C4267: '...': conversion from 'size_t' to 'unsigned int', possible loss of data
4347
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
4448
add_compile_options(-Weverything)
4549
# no need for c++98 compatibility

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ environment:
1010

1111
build_script:
1212
- ECHO Building %configuration% %platform% with MSVC %VisualStudioVersion% using %PlatformToolset% PlatformToolset
13-
- cmake -G "Visual Studio 14" .
13+
- cmake -DCMAKE_COMPILE_WARNING_AS_ERROR=On -G "Visual Studio 14" .
1414
- dir
1515
- 'CALL "C:\Program Files (x86)\Microsoft Visual Studio %VisualStudioVersion%\VC\vcvarsall.bat" %vcvarsall_platform%'
16+
- set _CL_=/WX
1617
- msbuild "simplecpp.sln" /consoleloggerparameters:Verbosity=minimal /target:Build /property:Configuration="%configuration%";Platform=%platform% /p:PlatformToolset=%PlatformToolset% /maxcpucount /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
1718

1819
test_script:

0 commit comments

Comments
 (0)