Skip to content

Commit 88c92e6

Browse files
authored
Fix compilation failure and warnings with NVHPC (#4744)
* 🚨 fix warnings Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 🚨 fix warnings Signed-off-by: Niels Lohmann <mail@nlohmann.me> * ⚗️ enable ranges support Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 🔥 remove ci_nvhpc job Signed-off-by: Niels Lohmann <mail@nlohmann.me> * ⚗️ enable ranges support Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 🔥 remove ci_nvhpc job Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 🚨 fix warning Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
1 parent 96c1b52 commit 88c92e6

6 files changed

Lines changed: 12 additions & 6 deletions

File tree

docs/mkdocs/docs/community/quality_assurance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ violations will result in a failed build.
7676
| GNU 13.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
7777
| GNU 14.2.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
7878
| GNU 14.2.0 | arm64 | Linux 6.1.100 | Cirrus CI |
79+
| icpc (ICC) 2021.5.0 20211109 | x86_64 | Ubuntu 20.04.3 LTS | GitHub |
7980
| MSVC 19.0.24241.7 | x86 | Windows 8.1 | AppVeyor |
8081
| MSVC 19.16.27035.0 | x86 | Windows-10 (Build 14393) | AppVeyor |
8182
| MSVC 19.29.30157.0 | x86 | Windows 10 (Build 17763) | GitHub |

include/nlohmann/detail/output/binary_writer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,9 @@ class binary_writer
973973
if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
974974
{
975975
JSON_THROW(out_of_range::create(409, concat("BSON key cannot contain code point U+0000 (at byte ", std::to_string(it), ")"), &j));
976-
static_cast<void>(j);
977976
}
978977

978+
static_cast<void>(j);
979979
return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
980980
}
981981

single_include/nlohmann/json.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16712,9 +16712,9 @@ class binary_writer
1671216712
if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
1671316713
{
1671416714
JSON_THROW(out_of_range::create(409, concat("BSON key cannot contain code point U+0000 (at byte ", std::to_string(it), ")"), &j));
16715-
static_cast<void>(j);
1671616715
}
1671716716

16717+
static_cast<void>(j);
1671816718
return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
1671916719
}
1672016720

tests/src/unit-iterators2.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ TEST_CASE("iterators 2")
955955
};
956956
json j_expected{"a_key", "b_key", "c_key"};
957957

958-
auto transformed = j.items() | std::views::transform([](const auto & item)
958+
// NOLINTNEXTLINE(fuchsia-trailing-return)
959+
auto transformed = j.items() | std::views::transform([](const auto & item) -> std::string_view
959960
{
960961
return item.key();
961962
});

tests/src/unit-regression2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ TEST_CASE("regression tests 2")
566566
const auto length = 300;
567567

568568
json dump_test;
569-
dump_test["1"] = std::string(length, -1);
569+
dump_test["1"] = std::string(length, static_cast<std::string::value_type>(-1));
570570

571571
std::string expected = R"({"1":")";
572572
for (int i = 0; i < length; ++i)
@@ -583,7 +583,7 @@ TEST_CASE("regression tests 2")
583583
const auto length = 500;
584584

585585
json dump_test;
586-
dump_test["1"] = std::string(length, -2);
586+
dump_test["1"] = std::string(length, static_cast<std::string::value_type>(-2));
587587

588588
std::string expected = R"({"1":")";
589589
for (int i = 0; i < length; ++i)

tests/src/unit-udt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ class Evil
841841
public:
842842
Evil() = default;
843843
template <typename T>
844-
Evil(T t) : m_i(sizeof(t))
844+
Evil(const T& t) : m_i(sizeof(t))
845845
{
846846
static_cast<void>(t); // fix MSVC's C4100 warning
847847
}
@@ -863,6 +863,10 @@ TEST_CASE("Issue #924")
863863
// silence Wunused-template warnings
864864
Evil e(1);
865865
CHECK(e.m_i >= 0);
866+
867+
// suppress warning: function "<unnamed>::Evil::Evil(T) [with T=std::string]" was declared but never referenced [declared_but_not_referenced]
868+
Evil e2(std::string("foo"));
869+
CHECK(e2.m_i >= 0);
866870
}
867871

868872
TEST_CASE("Issue #1237")

0 commit comments

Comments
 (0)