Skip to content
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

Add consteval format string checks for wide strings #2390

Closed
alabuzhev opened this issue Jun 26, 2021 · 3 comments
Closed

Add consteval format string checks for wide strings #2390

alabuzhev opened this issue Jun 26, 2021 · 3 comments

Comments

@alabuzhev
Copy link
Contributor

char-strings are properly rejected, but the same wchar_t-strings are happily compiled.

Example:

#include <string>
#include <string_view>

#include <fmt/core.h>
#include <fmt/xchar.h>

using namespace std::literals;

int main()
{
    fmt::format(L"{:d}", L"I am not a number");
    fmt::format(L"{:d}"s, L"I am not a number");
    fmt::format(L"{:d}"sv, L"I am not a number");

    fmt::format("{:d}", "I am not a number");
    fmt::format("{:d}"s, "I am not a number");
    fmt::format("{:d}"sv, "I am not a number");
}

Godbolt:
https://godbolt.org/z/jKr43Tqfs

@vitaut
Copy link
Contributor

vitaut commented Jun 26, 2021

Yeah, compile-time checks are currently enabled for the char overloads only.

alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 26, 2021
alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 26, 2021
alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 26, 2021
alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 26, 2021
alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 26, 2021
alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 26, 2021
alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 26, 2021
alabuzhev added a commit to alabuzhev/fmt that referenced this issue Jun 27, 2021
@vitaut vitaut changed the title consteval format check doesn't work with wchar_t strings Add consteval format string checks to wide strings Jul 2, 2021
@vitaut vitaut changed the title Add consteval format string checks to wide strings Add consteval format string checks for wide strings Jul 2, 2021
@vitaut
Copy link
Contributor

vitaut commented Sep 9, 2021

We also need to do this for function taking text styles and potentially named arguments.

@vitaut
Copy link
Contributor

vitaut commented Sep 13, 2022

This has been implemented in {fmt} v9.

@vitaut vitaut closed this as completed Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants