-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix std::filesystem::path regression #3073
Conversation
Digging into why Windows fails, I found something interesting. This code causes a SIGSEGV with 3.10.2: std::filesystem::path text_path("/tmp/text.txt");
json j(text_path); @TheAifam5 Have you ever constructed a JSON value with Before 3.10.3, this worked by accident, as
However, converting from a path to json never worked on Windows, as the conversion operator returns a So this is not a compatible string type for the library, so it tries to convert it to an array, and it crashes since We could introduce C++17-and-higher Any idea @nlohmann? |
@theodelrieu let me see the Bear project, will report to you shortly. EDIT 1: LOG 1:
|
@TheAifam5 Thanks, does that code work on Windows with 3.10.2? It should cause a stack overflow. |
The main problem is that On Windows, the Then, when performing the runtime conversion, it will just call |
I‘m on Linux. I have no access to Windows |
Well, it seems the problem was never spotted because there is no Windows support for bear: rizsotto/Bear#303 (comment) I'm confident that The library only supports UTF-8 (see https://github.com/nlohmann/json#character-encoding) so I think we can add C++17 overloads of EDIT: I don't know what happens when |
df1e572
to
d31b4ed
Compare
Should we constrain the overloads on whether or not |
You mean: whether the overload is only used in cases where a |
If a user has |
d31b4ed
to
5981ab8
Compare
Never tried it, and I don't expect it to work... |
Using different string types is currently hardly tested, because the library uses a lot of the |
These type traits performed an incorrect and insufficient check. Converting to a std::filesystem::path used to work by accident thanks to these brittle constraints, but the clean-up performed in nlohmann#3020 broke them.
5981ab8
to
68825f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Will this actually fix #3070? |
Yes, it will properly support |
Thanks a lot! |
While trying to fix #3090 with #3101, I begin to wonder whether it was a good idea to use I am currently thinking about guarding the conversion from/to @theodelrieu What do you think? |
I don't think the code using it will be instantiated unless it's actually used, so it shouldn't trigger linker flags if it's not used. |
I think you're right. I fixed all but one compiler: #3101 (comment) |
Antiquated type traits performed an incorrect and insufficient check.
std::filesystem::path
used to work by "chance" thanks to brittleconstraints, but the clean-up performed in #3020 broke these.
Fixes #3070
include/nlohmann
directory, runmake amalgamate
to create the single-header filesingle_include/nlohmann/json.hpp
. The whole process is described here.