Skip to content

#include <complex> fails to compile when using std=c++23 with libstdc++ and gcc 15.1 #139435

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

Closed
chriselrod opened this issue May 11, 2025 · 1 comment
Labels
c++23 clang:frontend Language frontend issues, e.g. anything involving "Sema" diverges-from:edg Does the clang frontend diverge from edg compiler diverges-from:gcc Does the clang frontend diverge from gcc on this issue diverges-from:msvc Does the clang frontend diverge from msvc on this issue duplicate Resolved as duplicate libstdc++ GNU libstdc++ C++ standard library

Comments

@chriselrod
Copy link

Test file, complex.cpp:

#include <complex>

int main(){
  return 0;
}

I get

❯ clang++ -stdlib=libstdc++ -std=c++20 complex.cpp

❯ clang++ -stdlib=libstdc++ -std=c++23 complex.cpp
In file included from format.cpp:1:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/complex:50:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/sstream:42:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/istream:43:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/ostream:44:
/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/format:5118:7: error: variable template 'format_kind' declared with deduced type 'const auto' cannot appear in its own initializer
 5118 |       format_kind<_Rg> // you can specialize this for non-const input ranges
      |       ^
1 error generated.

❯ g++ -std=c++23 complex.cpp

❯ g++ --version
g++ (GCC) 15.1.1 20250425
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


❯ clang++ --version
clang version 21.0.0git ([email protected]:llvm/llvm-project.git 066bc49f764cb24c8847d83a059684e3b6d7f4da)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/chriselrod/.local/stow/llvm/bin
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" c++23 libstdc++ GNU libstdc++ C++ standard library diverges-from:gcc Does the clang frontend diverge from gcc on this issue and removed new issue labels May 11, 2025
@llvmbot
Copy link
Member

llvmbot commented May 11, 2025

@llvm/issue-subscribers-clang-frontend

Author: Chris Elrod (chriselrod)

Test file, complex.cpp: ```c++ #include <complex>

int main(){
return 0;
}


I get

❯ clang++ -stdlib=libstdc++ -std=c++20 complex.cpp

❯ clang++ -stdlib=libstdc++ -std=c++23 complex.cpp
In file included from format.cpp:1:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/complex:50:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/sstream:42:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/istream:43:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/ostream:44:
/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/format:5118:7: error: variable template 'format_kind' declared with deduced type 'const auto' cannot appear in its own initializer
5118 | format_kind<_Rg> // you can specialize this for non-const input ranges
| ^
1 error generated.

❯ g++ -std=c++23 complex.cpp

❯ g++ --version
g++ (GCC) 15.1.1 20250425
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

❯ clang++ --version
clang version 21.0.0git ([email protected]:llvm/llvm-project.git 066bc49)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/chriselrod/.local/stow/llvm/bin

</details>

@frederick-vs-ja frederick-vs-ja added duplicate Resolved as duplicate diverges-from:msvc Does the clang frontend diverge from msvc on this issue diverges-from:edg Does the clang frontend diverge from edg compiler labels May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++23 clang:frontend Language frontend issues, e.g. anything involving "Sema" diverges-from:edg Does the clang frontend diverge from edg compiler diverges-from:gcc Does the clang frontend diverge from gcc on this issue diverges-from:msvc Does the clang frontend diverge from msvc on this issue duplicate Resolved as duplicate libstdc++ GNU libstdc++ C++ standard library
Projects
None yet
Development

No branches or pull requests

4 participants