Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wconversion warnings #239

Closed
Aykelith opened this issue Apr 28, 2016 · 7 comments
Closed

-Wconversion warnings #239

Aykelith opened this issue Apr 28, 2016 · 7 comments
Assignees
Milestone

Comments

@Aykelith
Copy link

Aykelith commented Apr 28, 2016

I'm using g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 5.3.0 and g++ (i686-posix-dwarf-rev1, Built by MinGW-W64 project) 4.9.2 and I'm getting this:

In file included from ..\path\StateMachine.cpp:3:0:
../path/json/json.hpp: In instantiation of 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::type_data_t& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::type_data_t::operator=(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::value_t) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]':
../path/json/json.hpp:2037:22: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>&&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]'
../path/json/json.hpp:9568:98: required from here
../path/json/json.hpp:760:23: warning: conversion to 'unsigned char:4' from 'uint16_t {aka short unsigned int}' may alter its value [-Wconversion]
bits.type = static_cast<uint16_t>(rhs);
^
In file included from ..\path\StateMachine.cpp:3:0:
../path/json/json.hpp: In instantiation of 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&)::<lambda(char)> [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]':
../path/json/json.hpp:6081:40: required from 'struct nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]::<lambda(char)>'
../path/json/json.hpp:6084:25: required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]'
../path/json/json.hpp:6162:48: required from 'void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(std::ostream&, bool, unsigned int, unsigned int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; std::ostream = std::basic_ostream]'
../path/json/json.hpp:2167:61: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]'
../path/json/json.hpp:9549:25: required from here
../path/json/json.hpp:6083:72: warning: conversion to 'char' from 'int' may alter its value [-Wconversion]
return (v < 10) ? ('0' + v) : ('a' + v - 10);
^
../path/json/json.hpp:6083:72: warning: conversion to 'char' from 'int' may alter its value [-Wconversion]
../path/json/json.hpp: In instantiation of 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]':
../path/json/json.hpp:6162:48: required from 'void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(std::ostream&, bool, unsigned int, unsigned int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; std::ostream = std::basic_ostream]'
../path/json/json.hpp:2167:61: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]'
../path/json/json.hpp:9549:25: required from here
../path/json/json.hpp:6088:51: warning: conversion to 'char' from 'int' may alter its value [-Wconversion]
{ 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
^
In file included from ..\path\StateMachine.cpp:3:0:
../path/json/json.hpp: In instantiation of 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::type_data_t::type_data_t(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::value_t) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]':
../path/json/json.hpp:1060:5: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::parser::parse() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]'
../path/json/json.hpp:5837:36: required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::parse(const string_t&, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::parser_callback_t) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::parser_callback_t = std::function<bool(int, nlohmann::basic_json<>::parse_event_t, nlohmann::basic_json<>&)>]'
../path/json/json.hpp:9568:98: required from here
../path/json/json.hpp:768:23: warning: conversion to 'unsigned char:4' from 'uint16_t {aka short unsigned int}' may alter its value [-Wconversion]
bits.type = static_cast<uint16_t>(t);

@nlohmann
Copy link
Owner

Hi @Aykelith, thanks for reporting. As I do not have a Mingw compiler at hand, could you please try the code at https://github.com/nlohmann/json/tree/feature/issue239 which should have less/no warnings.

@nlohmann nlohmann self-assigned this Apr 29, 2016
@Aykelith
Copy link
Author

json.hpp: In instantiation of 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::type_data_t& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::type_data_t::operator=(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::value_t) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]':
json.hpp:2037:22: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>&&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]'
json.hpp:9570:98: required from here
json.hpp:760:23: warning: conversion to 'unsigned char:4' from 'uint16_t {aka short unsigned int}' may alter its value [-Wconversion]
bits.type = static_cast<uint16_t>(rhs);
^
json.hpp: In instantiation of 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::type_data_t::type_data_t(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::value_t) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]':
json.hpp:1060:5: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::value_type& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::operator[](nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::size_type) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::reference = nlohmann::basic_json<>&; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::value_type = nlohmann::basic_json<>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::size_type = unsigned int]'
Platform\TerrainInfo.cpp:15:44: required from here
json.hpp:768:23: warning: conversion to 'unsigned char:4' from 'uint16_t {aka short unsigned int}' may alter its value [-Wconversion]
bits.type = static_cast<uint16_t>(t);
^
In file included from Platform\TerrainInfo.cpp:3:0:
json.hpp: In instantiation of 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&)::<lambda(int)> [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]':
json.hpp:6081:46: required from 'struct nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]::<lambda(int)>'
json.hpp:6086:25: required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]'
json.hpp:6164:48: required from 'void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(std::ostream&, bool, unsigned int, unsigned int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; std::ostream = std::basic_ostream]'
json.hpp:2167:61: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]'
json.hpp:9551:25: required from here
json.hpp:6085:63: warning: conversion to 'char' from 'int' may alter its value [-Wconversion]
: ('a' + static_cast(v - 10));
^
json.hpp:6085:63: warning: conversion to 'char' from 'int' may alter its value [-Wconversion]

@nlohmann
Copy link
Owner

@Aykelith, thanks for checking! I made another change that should get rid of more warnings. Could you please try https://github.com/nlohmann/json/tree/feature/issue239 again?

@Aykelith
Copy link
Author

Aykelith commented May 2, 2016

In file included from Platform\TerrainInfo.cpp:3:0:
json/json.hpp: In instantiation of 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&)::<lambda(int)> [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator]':
json/json.hpp:6081:46: required from 'struct nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]::<lambda(int)>'
json/json.hpp:6086:25: required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]'
json/json.hpp:6164:48: required from 'void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(std::ostream&, bool, unsigned int, unsigned int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; std::ostream = std::basic_ostream]'
json/json.hpp:2167:61: required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::dump(int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::string_t = std::basic_string]'
json/json.hpp:9551:25: required from here
json/json.hpp:6085:72: warning: conversion to 'char' from 'int' may alter its value [-Wconversion]
: ('a' + static_cast((v - 10) & 0xff));
^
json/json.hpp:6085:72: warning: conversion to 'char' from 'int' may alter its value [-Wconversion]

@nlohmann
Copy link
Owner

nlohmann commented May 8, 2016

@Aykelith - I made another attempt to fix the warning - see https://github.com/nlohmann/json/tree/feature/issue239.

@Aykelith
Copy link
Author

No more warnings :D

@nlohmann nlohmann added this to the Release 2.0.0 milestone May 11, 2016
nlohmann added a commit that referenced this issue May 11, 2016
@nlohmann
Copy link
Owner

Thanks for reporting and checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants