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

formatting a std::optional with format_as function fails to compile using clang #3712

Closed
cptFracassa opened this issue Nov 13, 2023 · 1 comment · Fixed by #3713
Closed

Comments

@cptFracassa
Copy link
Contributor

clang reports compiler error for code that formats a variable of type std::optional, where T is an enum with a format_as custom formatter. The same code compiles fine with gcc or msvc.
gobolt example

The compiler error is due to the optional formatter (in fmt/std.h) calling u.set_debug_format(set); on line 170, and this function being private due to private inheritance (fmt/format.h - line 4055.

Adding the following line to fmt/format line 4058 solves the problem: using base::set_debug_format;. Alternatively, changing from private to public inheritance on line 4055 fixes it too.

@cptFracassa cptFracassa changed the title formatting a std::optional with a format_as function fails to compile on clang formatting a std::optional with format_as function fails to compile using clang Nov 13, 2023
@ecatmur
Copy link

ecatmur commented Nov 15, 2023

caused by llvm/llvm-project#68849

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

Successfully merging a pull request may close this issue.

2 participants