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

char8_t formatting converts to integers #1188

Closed
cjdb opened this issue Jun 1, 2019 · 7 comments
Closed

char8_t formatting converts to integers #1188

cjdb opened this issue Jun 1, 2019 · 7 comments

Comments

@cjdb
Copy link
Contributor

cjdb commented Jun 1, 2019

#include <fmt/format.h>

int main()
{
    auto x = fmt::format(u8"{}", u8'a');

    for (auto const c : x) {
       fmt::print("{}", static_cast<char>(c));
    }
    fmt::print("\n");
}

The above program will format u8'a' as 97, not a. Is this to be expected, WIP, or a bug?

@vitaut
Copy link
Contributor

vitaut commented Jun 2, 2019

Should print a. What compiler/flags? Seems to be working as expected on clang-1001.0.46.4 with -std=c++2a.

@vitaut
Copy link
Contributor

vitaut commented Jun 2, 2019

Should be covered by this case:

FMT_CONSTEXPR init<C, int, char_type> make_value(Char val) {

@cjdb
Copy link
Contributor Author

cjdb commented Jun 2, 2019

What compiler/flags?

For the above example, on my Disco Docker:

root@acd1394df98b:/# g++-8 -std=c++2a -g -I fmt/include/ hello.cpp fmt/src/format.cc fmt/src/posix.cc -o hello
root@acd1394df98b:/# ./hello
a
root@acd1394df98b:/# g++-9 -std=c++2a -g -I fmt/include/ hello.cpp fmt/src/format.cc fmt/src/posix.cc -o hello
root@acd1394df98b:/# ./hello
97

Looks as though it's a GCC 9 regression.

@vitaut
Copy link
Contributor

vitaut commented Jun 2, 2019

Could be some overload resolution weirdness, but I don't see how anything can be a better match than the Char overload above.

@vitaut
Copy link
Contributor

vitaut commented Jun 3, 2019

Actually argument capture works fine. The problem is in lower level functions that have never been updated to handle exotic character types:

void write(wchar_t value) {

@vitaut
Copy link
Contributor

vitaut commented Jun 4, 2019

Fixed in eddb84c.

@vitaut vitaut closed this as completed Jun 4, 2019
@cjdb
Copy link
Contributor Author

cjdb commented Jun 5, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants