-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Implicit type conversion error on MSVC #1333
Comments
I can confirm the code does not compile with Clang (tried Xcode 10). I also agree that the result right now is wrong, but I am not sure why MSVC behaves differently here. |
My current workaround is to provide operators for json type and an arithmetic type, e.g.
It solves the problem but I'm wondering if there is a more elegant way. Edit: The workaround only works for simple cases. json * json * double would fail. Edit: Seems to be related to #958 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Thanks for your response. If implicit conversion is allowed but can potentially produce wrong result, it might be a good idea to disable it all together, at least for MSVC. BTW, I created a PR as the link to #958 is broken in ReadMe.md. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
What is the issue you have?
Wrong type is deduced when json object is use in an expression with some other arithmetic types.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
What is the expected behavior?
It should either fail to compile (as it does in gcc and clang), or deduce the correct type when mixed with arithmetic types in an expression and prints 12.34 and 0.1234.
And what is the actual behavior instead?
MSVC compilation succeeds without error/warning (with /W4 and /permissive- flag). The second
_j["Value"]
calls the implicit conversion function with unsigned int type, converts it to double, then does the multiplication. It prints 12.34 and 0.12 instead.Which compiler and operating system are you using? Is it a supported compiler?
MSVC 15.8.8 on Windows 10, x64
Did you use a released version of the library or the version from the
develop
branch?3.3 (through vcpkg)
If you experience a compilation error: can you compile and run the unit tests?
No compilation error.
The text was updated successfully, but these errors were encountered: