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

Compile Error with C++20 & Clang 20 (FMT_STRING macro issue) #4247

Closed
ahoarau opened this issue Nov 29, 2024 · 3 comments
Closed

Compile Error with C++20 & Clang 20 (FMT_STRING macro issue) #4247

ahoarau opened this issue Nov 29, 2024 · 3 comments

Comments

@ahoarau
Copy link

ahoarau commented Nov 29, 2024

Hi,
I've having a compile error while testing the upcoming clang 20 with c++20 (and above).
It looks like #4218, but I could not manage to find a working patch.

#include <fmt/format.h>
int main() { fmt::print("{}", 42); }

Compiler error:

cmake_minimum_required(VERSION 3.24)
project(clang20-fmt)

set(CMAKE_CXX_STANDARD 20) # fmt will build with c++20
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(
  fmt
  URL https://github.com/fmtlib/fmt/releases/download/11.0.2/fmt-11.0.2.zip
)
FetchContent_MakeAvailable(fmt)

add_executable(example example.cc)
target_link_libraries(example PRIVATE fmt::fmt)

Here's a snippet of the output, seems to be an issue with the FMT_STRING(s) macro:

[build] /dev/clang20-fmt/build/Debug/_deps/fmt-src/src/os.cc:176:35: error: call to consteval function 'fmt::basic_format_string<char, const char *>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
[build]   176 |     FMT_THROW(system_error(errno, FMT_STRING("cannot open file {}"),

Complete output:
2-CMakeBuild.log

The project (you need clang built from main branch !):
clang20-fmt.zip

@vitaut
Copy link
Contributor

vitaut commented Nov 30, 2024

Looks like #4177 which has already been fixed. Does it work on master?

@ahoarau
Copy link
Author

ahoarau commented Nov 30, 2024

@vitaut Compiles on master, thanks ! a 11.0.3 coming up soon ?

@vitaut
Copy link
Contributor

vitaut commented Nov 30, 2024

a 11.0.3 coming up soon ?

Yes by some definition of soon.

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