From e65db8344815eb1fbdd05b3d4449ed6f53348952 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 13 Aug 2021 12:42:38 +0200 Subject: [PATCH 1/5] :alembic: add -WX flag to MSVC builds --- .github/workflows/windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fad51b632e..adf6633082 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -56,7 +56,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: cmake - run: cmake -S . -B build -G "Visual Studio 15 2017" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4" + run: cmake -S . -B build -G "Visual Studio 15 2017" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX" - name: build run: cmake --build build --config Release --parallel 10 - name: test @@ -88,7 +88,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4" + run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX" - name: build run: cmake --build build --config Release --parallel 10 - name: test From 789280fcb2d2176a4e1d393a201e699c9dbb75de Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 13 Aug 2021 13:20:26 +0200 Subject: [PATCH 2/5] :rotating_light: fix C4309 warning --- test/src/unit-deserialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 293d2418fb..ad96343a0a 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -1089,7 +1089,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (UTF-8)", T, char, unsigned char, std::uint8_t) { // a star emoji - std::vector v = {'"', static_cast(0xe2), static_cast(0xad), static_cast(0x90), static_cast(0xef), static_cast(0xb8), static_cast(0x8f), '"'}; + std::vector v = {'"', static_cast(0xe2u), static_cast(0xadu), static_cast(0x90u), static_cast(0xefu), static_cast(0xb8u), static_cast(0x8fu), '"'}; CHECK(json::parse(v).dump(-1, ' ', true) == "\"\\u2b50\\ufe0f\""); CHECK(json::accept(v)); From fecb01858b9ffe9ea7b2fc10bc20ecdef4b201ec Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 13 Aug 2021 13:28:17 +0200 Subject: [PATCH 3/5] :alembic: add -WX flag to MSVC builds --- .github/workflows/windows.yml | 10 +++++----- appveyor.yml | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index adf6633082..4978e5d973 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -37,13 +37,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: cmake - run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_EXE_LINKER_FLAGS="/STACK:4000000" + run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_EXE_LINKER_FLAGS="/STACK:4000000" -DCMAKE_CXX_FLAGS="/W4 /WX" if: matrix.build_type == 'Release' && matrix.architecture == 'x64' - name: cmake - run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On + run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX" if: matrix.build_type == 'Release' && matrix.architecture != 'x64' - name: cmake - run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON + run: cmake -S . -B build -G "Visual Studio 15 2017" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX" if: matrix.build_type == 'Debug' - name: build run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 @@ -72,10 +72,10 @@ jobs: steps: - uses: actions/checkout@v2 - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On + run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX" if: matrix.build_type == 'Release' - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON + run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX" if: matrix.build_type == 'Debug' - name: build run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 diff --git a/appveyor.yml b/appveyor.yml index 4dba417c63..0157e20811 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 configuration: Debug platform: x86 - CXX_FLAGS: "" + CXX_FLAGS: "/W4 /WX" LINKER_FLAGS: "" CMAKE_OPTIONS: "" GENERATOR: Visual Studio 14 2015 @@ -13,7 +13,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 configuration: Release platform: x86 - CXX_FLAGS: "" + CXX_FLAGS: "/W4 /WX" LINKER_FLAGS: "" CMAKE_OPTIONS: "" GENERATOR: Visual Studio 14 2015 @@ -22,7 +22,7 @@ environment: configuration: Release platform: x86 name: with_win_header - CXX_FLAGS: "" + CXX_FLAGS: "/W4 /WX" LINKER_FLAGS: "" CMAKE_OPTIONS: "" GENERATOR: Visual Studio 14 2015 @@ -30,7 +30,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 configuration: Release platform: x86 - CXX_FLAGS: "/permissive- /std:c++latest /utf-8" + CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /W4 /WX" LINKER_FLAGS: "" CMAKE_OPTIONS: "" GENERATOR: Visual Studio 15 2017 @@ -38,7 +38,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 configuration: Release platform: x86 - CXX_FLAGS: "" + CXX_FLAGS: "/W4 /WX" LINKER_FLAGS: "" CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF" GENERATOR: Visual Studio 16 2019 @@ -46,7 +46,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 configuration: Release platform: x64 - CXX_FLAGS: "" + CXX_FLAGS: "/W4 /WX" LINKER_FLAGS: "" CMAKE_OPTIONS: "" GENERATOR: Visual Studio 14 2015 @@ -54,7 +54,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 configuration: Release platform: x64 - CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000" + CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000 /W4 /WX" LINKER_FLAGS: "/STACK:4000000" CMAKE_OPTIONS: "" GENERATOR: Visual Studio 15 2017 From 288cdf9af7eb1d8f7e93989450942b32e275650c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 13 Aug 2021 14:07:17 +0200 Subject: [PATCH 4/5] :alembic: add -WX flag to MSVC builds --- test/src/unit-allocator.cpp | 4 ++++ test/src/unit-udt.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index 962828d201..c68e1886b8 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -100,6 +100,9 @@ struct my_allocator : std::allocator std::allocator::deallocate(p, n); } + // the code below warns about p in MSVC 2015 - this could be a bug + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH + DOCTEST_MSVC_SUPPRESS_WARNING(4100) void destroy(T* p) { if (next_destroy_fails) @@ -110,6 +113,7 @@ struct my_allocator : std::allocator p->~T(); } + DOCTEST_MSVC_SUPPRESS_WARNING_POP template struct rebind diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 2bebd8f599..7871a7fba0 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -809,6 +809,10 @@ TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated static_assert(!is_constructible_patched::value, ""); } +// the code below warns about t in MSVC 2015 - this could be a bug +DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +DOCTEST_MSVC_SUPPRESS_WARNING(4100) + namespace { class Evil @@ -821,6 +825,8 @@ class Evil int m_i = 0; }; +DOCTEST_MSVC_SUPPRESS_WARNING_POP + void from_json(const json& /*unused*/, Evil& /*unused*/) {} } // namespace From 4b0e04eb685b9ce8cb563177c5aaea9f7002fbf9 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 13 Aug 2021 17:03:55 +0200 Subject: [PATCH 5/5] :rotating_light: fix C4100 warnings --- test/src/unit-allocator.cpp | 5 +---- test/src/unit-udt.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index c68e1886b8..7b5a36090d 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -100,9 +100,6 @@ struct my_allocator : std::allocator std::allocator::deallocate(p, n); } - // the code below warns about p in MSVC 2015 - this could be a bug - DOCTEST_MSVC_SUPPRESS_WARNING_PUSH - DOCTEST_MSVC_SUPPRESS_WARNING(4100) void destroy(T* p) { if (next_destroy_fails) @@ -111,9 +108,9 @@ struct my_allocator : std::allocator throw std::bad_alloc(); } + static_cast(p); // fix MSVC's C4100 warning p->~T(); } - DOCTEST_MSVC_SUPPRESS_WARNING_POP template struct rebind diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 7871a7fba0..12770ce64d 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -809,10 +809,6 @@ TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated static_assert(!is_constructible_patched::value, ""); } -// the code below warns about t in MSVC 2015 - this could be a bug -DOCTEST_MSVC_SUPPRESS_WARNING_PUSH -DOCTEST_MSVC_SUPPRESS_WARNING(4100) - namespace { class Evil @@ -820,13 +816,14 @@ class Evil public: Evil() = default; template - Evil(T t) : m_i(sizeof(t)) {} + Evil(T t) : m_i(sizeof(t)) + { + static_cast(t); // fix MSVC's C4100 warning + } int m_i = 0; }; -DOCTEST_MSVC_SUPPRESS_WARNING_POP - void from_json(const json& /*unused*/, Evil& /*unused*/) {} } // namespace