-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Strange interaction with {fmt} and std::filesystem/std::experimental::filesystem #729
Comments
Typically the fist path component ("somedir") ends up as null bytes in s. |
The problem is implicit conversion from path to a temporary string that goes out of scope before formatting. I need to think how to catch such cases. |
The regression was introduced in 18ac987. Before that it would result in a compile-time error. |
Disabled the unsafe conversion in d940fa6. Now the problematic code will result in a compile-time error which can be resolved either by falling back to ostream (include namespace fmt {
template <>
struct formatter<std::experimental::filesystem::path> : formatter<std::string> {};
} Thanks for catching this! |
Rather than disabling this, wouldn't it be better to replace |
@alabuzhev, I was thinking of ways to extend lifetimes of temporaries, but all the solutions that I've found so far, including the additional indirection that you suggest, require extra hoops from the user (and still possible to misuse). Since the use of implicit conversions is normally discouraged anyway I think it's better to prioritize the simplicity of argument capturing API. Types with implicit conversions are easy to support through the normal formatter API. |
@vitaut, thanks for the explanation - I didn't realise that there's an API which might get too complicated so it just looked like a purely artificial limitation. |
I have a small test that gives weird results:
(test transcribed so might contain errors)
s ends up having some weird contents that I cannot see how it gets.
(this is with GCC-8 in C++14 mode.)
The text was updated successfully, but these errors were encountered: