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
|
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::pathused to work by "chance" thanks to brittleconstraints, but the clean-up performed in #3020 broke these.
Fixes #3070
include/nlohmanndirectory, runmake amalgamateto create the single-header filesingle_include/nlohmann/json.hpp. The whole process is described here.