You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to convert a nlohmann::json object which contains an unsigned int of 64 bit length breaks BSON conversion.
I do consider this to be a bug, as BSON should be capable of handling those values [1] , but the corresponding header-bits are not set in write_bson_unsigned. Only entry headers 0x10 (for int32) and 0x12 (for int64) are written, but 11 (for uint_64) is not.
Reproduction steps
This bug is triggered whenever one uses the json::to_bson function on any object that contains an uint64_t, that really uses all 64 bits.
Expected vs. actual results
I expect BSON to generated, but I get an error message (see below)
Minimal code example
#include <map>#include <string>#include <nlohmann/json.hpp>
int main(){
std::map<size_t,std::string> m={{14631357879723465589u /*really just any large enough uint64_number*/,"To_Big"}};
nlohmann::json j;
j["map"]=m;
auto bson=nlohmann::json::to_bson(j); //can not be converted
}
Error messages
terminate called after throwing an instance of 'nlohmann::detail::out_of_range'what(): [json.exception.out_of_range.407] integer number 14631357879723465589 cannot be represented by BSON as it does not fit int64
Compiler and operating system
Clang-13 on Mint 21 64bit, Clang Trunk (via godbolt)
Library version
3.11.2 (develop branch via godbolt) , 3.10.5
Validation
The bug also occurs if the latest version from the develop branch is used.
Description
Trying to convert a nlohmann::json object which contains an unsigned int of 64 bit length breaks BSON conversion.
I do consider this to be a bug, as BSON should be capable of handling those values [1] , but the corresponding header-bits are not set in write_bson_unsigned. Only entry headers
0x10
(forint32
) and0x12
(forint64
) are written, but11
(foruint_64
) is not.Reproduction steps
This bug is triggered whenever one uses the
json::to_bson
function on any object that contains an uint64_t, that really uses all 64 bits.Expected vs. actual results
I expect BSON to generated, but I get an error message (see below)
Minimal code example
Error messages
Compiler and operating system
Clang-13 on Mint 21 64bit, Clang Trunk (via godbolt)
Library version
3.11.2 (develop branch via godbolt) , 3.10.5
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: