Skip to content

Commit

Permalink
🚨 removing compiler warnings #755
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Sep 30, 2017
1 parent 1a66527 commit 8af49d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/json.hpp
Expand Up @@ -62,7 +62,7 @@ SOFTWARE.
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#elif defined(__GNUC__)
#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#endif
Expand Down Expand Up @@ -6320,7 +6320,7 @@ class serializer
*/
static constexpr std::size_t bytes_following(const uint8_t u)
{
return ((0 <= u and u <= 127) ? 0
return ((u <= 127) ? 0
: ((192 <= u and u <= 223) ? 1
: ((224 <= u and u <= 239) ? 2
: ((240 <= u and u <= 247) ? 3 : std::string::npos))));
Expand Down Expand Up @@ -6660,7 +6660,7 @@ class serializer
return;
}

const bool is_negative = x < 0;
const auto is_negative = std::signbit(x);
std::size_t i = 0;

// spare 1 byte for '\0'
Expand Down Expand Up @@ -9759,7 +9759,7 @@ class basic_json
, "incompatible pointer type");

// delegate the call to get_impl_ptr<>() const
return get_impl_ptr(static_cast<const PointerType>(nullptr));
return get_impl_ptr(static_cast<PointerType>(nullptr));
}

/*!
Expand Down
4 changes: 2 additions & 2 deletions test/src/unit-cbor.cpp
Expand Up @@ -739,13 +739,13 @@ TEST_CASE("CBOR")
{
SECTION("no byte follows")
{
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9})), json::parse_error);
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9})), json::parse_error&);
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf9})),
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
}
SECTION("only one byte follows")
{
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})), json::parse_error);
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})), json::parse_error&);
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})),
"[json.exception.parse_error.110] parse error at 3: unexpected end of input");
}
Expand Down
22 changes: 11 additions & 11 deletions test/src/unit-deserialization.cpp
Expand Up @@ -451,11 +451,11 @@ TEST_CASE("deserialization")

SECTION("BOM only")
{
CHECK_THROWS_AS(json::parse(bom), json::parse_error);
CHECK_THROWS_AS(json::parse(bom), json::parse_error&);
CHECK_THROWS_WITH(json::parse(bom),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");

CHECK_THROWS_AS(json::parse(std::istringstream(bom)), json::parse_error);
CHECK_THROWS_AS(json::parse(std::istringstream(bom)), json::parse_error&);
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
}
Expand All @@ -468,22 +468,22 @@ TEST_CASE("deserialization")

SECTION("2 byte of BOM")
{
CHECK_THROWS_AS(json::parse(bom.substr(0, 2)), json::parse_error);
CHECK_THROWS_AS(json::parse(bom.substr(0, 2)), json::parse_error&);
CHECK_THROWS_WITH(json::parse(bom),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");

CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error);
CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error&);
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
}

SECTION("1 byte of BOM")
{
CHECK_THROWS_AS(json::parse(bom.substr(0, 1)), json::parse_error);
CHECK_THROWS_AS(json::parse(bom.substr(0, 1)), json::parse_error&);
CHECK_THROWS_WITH(json::parse(bom),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");

CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error);
CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error&);
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
}
Expand All @@ -504,9 +504,9 @@ TEST_CASE("deserialization")
CAPTURE(i2);

std::string s = "";
s.push_back(bom[0] + i0);
s.push_back(bom[1] + i1);
s.push_back(bom[2] + i2);
s.push_back(static_cast<char>(bom[0] + i0));
s.push_back(static_cast<char>(bom[1] + i1));
s.push_back(static_cast<char>(bom[2] + i2));

if (i0 == 0 and i1 == 0 and i2 == 0)
{
Expand All @@ -517,8 +517,8 @@ TEST_CASE("deserialization")
else
{
// any variation is an error
CHECK_THROWS_AS(json::parse(s + "null"), json::parse_error);
CHECK_THROWS_AS(json::parse(std::istringstream(s + "null")), json::parse_error);
CHECK_THROWS_AS(json::parse(s + "null"), json::parse_error&);
CHECK_THROWS_AS(json::parse(std::istringstream(s + "null")), json::parse_error&);
}
}
}
Expand Down

4 comments on commit 8af49d4

@NuclearC
Copy link

Choose a reason for hiding this comment

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

Please help me

VC++ 2017 throws error when compiling:

error C2668: 'signbit': ambiguous call to overloaded function

@nlohmann
Copy link
Owner Author

Choose a reason for hiding this comment

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

Related: #761

@nlohmann
Copy link
Owner Author

Choose a reason for hiding this comment

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

@NuclearC This should be fixed.

@NuclearC
Copy link

Choose a reason for hiding this comment

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

@nlohmann yeah #1df836c fixed it

Please sign in to comment.