Skip to content

No exception raised for Out Of Range input of numbers #647

Description

@MichaelHuth

Hello,

if one has values that are beyond the range of the target type no exception is raised.

e.g. this code with a value of UINT64_MAX+1 and 10000 for the target of a signed char outputs 0 and 16 respectively.

	json jtest = json::parse("{\"value\" : 18446744073709551617}");
	std::cout << std::to_string(jtest["value"].get<unsigned long long int>()) << "\n";
	jtest = json::parse("{\"value\" : 10000}");
	std::cout << std::to_string(jtest["value"].get<signed char>()) << "\n";

Both cases should throw an exception.

Best regards.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions