Check make_format_args's preconditions - #3080
Merged
Stephan T. Lavavej (StephanTLavavej) merged 2 commits intoOct 12, 2022
Merged
Check make_format_args's preconditions#3080Stephan T. Lavavej (StephanTLavavej) merged 2 commits into
make_format_args's preconditions#3080Stephan T. Lavavej (StephanTLavavej) merged 2 commits into
Conversation
Contributor
|
I'm scared that this is going to blow up because we got the nuances of the type mapping machinery confused again, somehow. I'm worried about types where formatability depends on cvref qualifiers |
Contributor
|
I couldn't come up with any cases where this error does not agree with the later concept failure, and this actually is an error improvement. |
Charlie Barto (barcharcraz)
approved these changes
Sep 22, 2022
Co-authored-by: Sam Huang <samestimable2016@gmail.com>
Stephan T. Lavavej (StephanTLavavej)
approved these changes
Sep 23, 2022
Member
|
I've added Standardese citations as recommended by @sam20908 (thanks!). Note that the same paragraph is cited for narrow and wide because of Effects Equivalent To wording. ✅ No modules impact. |
Member
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Member
|
Thanks for this diagnostic improvement! 🎉 💡 😸 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[format.arg.store]
Currently, this precondition isn't checked. If an user passes an unformattable type, the error message will likely start with "'std::_Format_arg_traits<_Context>::_Phony_basic_format_arg_constructor': none of the 5 overloads could convert all the argument types", which isn't quite helpful.
Before LWG-3701, It was impractical to check this precondition, because even
std::format("Hello {}!\n", "world")was a precondition violation. This is no longer a concern after LWG-3701 lands.The error message was copied from fmtlib (https://github.com/fmtlib/fmt/blob/1feb430faaac6bd8094e996861d6025f9903d34e/include/fmt/core.h#L1771-L1772).