[libcxx-commits] [libcxx] [llvm] [libc++] Upgrade to GCC16 (PR #206235)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 27 02:27:25 PDT 2026


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/206235

This also removes a few `// UNSUPPORTED: gcc` which are unnecessary as a drive-by.


>From 10cd8965bd50cbdaa3e6737d61229b74080ade98 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sat, 27 Jun 2026 11:11:40 +0200
Subject: [PATCH] [libc++] Upgrade to GCC16

---
 .github/workflows/libcxx-build-and-test.yaml              | 8 ++++----
 libcxx/docs/index.rst                                     | 2 +-
 libcxx/include/__configuration/compiler.h                 | 4 ++--
 libcxx/include/__ranges/concat_view.h                     | 5 ++---
 libcxx/src/experimental/time_zone.cpp                     | 6 ------
 .../test/libcxx/type_traits/desugars_to.compile.pass.cpp  | 2 +-
 .../function.objects/refwrap/desugars_to.compile.pass.cpp | 2 +-
 .../libcxx/utilities/meta/is_within_lifetime.verify.cpp   | 1 -
 libcxx/test/selftest/pass.cpp/werror.pass.cpp             | 3 ---
 libcxx/test/selftest/sh.cpp/werror.sh.cpp                 | 3 ---
 .../flat.map.modifiers/try_emplace_transparent.pass.cpp   | 2 --
 .../std/depr/depr.c.headers/stdalign_h.compile.pass.cpp   | 3 ---
 .../expected/expected.expected/monadic/transform.pass.cpp | 2 +-
 .../expected.expected/monadic/transform_error.pass.cpp    | 2 +-
 .../expected.void/monadic/transform_error.pass.cpp        | 2 +-
 .../format.formatter.spec/formatter.char_array.pass.cpp   | 2 +-
 .../meta.const.eval/is_within_lifetime.compile.pass.cpp   | 2 +-
 .../meta.unary.prop/is_implicit_lifetime.pass.cpp         | 5 ++---
 .../tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp        | 2 +-
 19 files changed, 19 insertions(+), 39 deletions(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index f02f3ae5b0782..a047db494919f 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -51,8 +51,8 @@ jobs:
         cxx: [ 'clang++-23' ]
         include:
           - config: 'generic-gcc'
-            cc: 'gcc-15'
-            cxx: 'g++-15'
+            cc: 'gcc-16'
+            cxx: 'g++-16'
     steps:
       - uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
         with:
@@ -96,8 +96,8 @@ jobs:
         cxx: [ 'clang++-23' ]
         include:
           - config: 'generic-gcc-cxx11'
-            cc: 'gcc-15'
-            cxx: 'g++-15'
+            cc: 'gcc-16'
+            cxx: 'g++-16'
           - config: 'generic-cxx26'
             cc: 'clang-22'
             cxx: 'clang++-22'
diff --git a/libcxx/docs/index.rst b/libcxx/docs/index.rst
index 13aa481b1f9b7..816c2543cbabc 100644
--- a/libcxx/docs/index.rst
+++ b/libcxx/docs/index.rst
@@ -136,7 +136,7 @@ Compiler     Versions            Restrictions               Support policy
 Clang        21, 22, 23-git                                 latest two stable releases per `LLVM's release page <https://releases.llvm.org>`_ and the development version
 AppleClang   26.4                                           latest stable release per `Xcode's release page <https://developer.apple.com/documentation/xcode-release-notes>`_
 Open XL      17.1.4 (AIX)                                   latest stable release per `Open XL's documentation page <https://www.ibm.com/docs/en/openxl-c-and-cpp-aix>`_
-GCC          15                  In C++11 or later only     latest stable release per `GCC's release page <https://gcc.gnu.org/releases.html>`_
+GCC          16                  In C++11 or later only     latest stable release per `GCC's release page <https://gcc.gnu.org/releases.html>`_
 ============ =================== ========================== =====================
 
 Libc++ also supports common platforms and architectures:
diff --git a/libcxx/include/__configuration/compiler.h b/libcxx/include/__configuration/compiler.h
index 264b713d94b6a..2c9b4b294dd45 100644
--- a/libcxx/include/__configuration/compiler.h
+++ b/libcxx/include/__configuration/compiler.h
@@ -41,8 +41,8 @@
 #      warning "Libc++ only supports AppleClang 26.4 and later"
 #    endif
 #  elif defined(_LIBCPP_GCC_VER)
-#    if _LIBCPP_GCC_VER < 1500
-#      warning "Libc++ only supports GCC 15 and later"
+#    if _LIBCPP_GCC_VER < 1600
+#      warning "Libc++ only supports GCC 16 and later"
 #    endif
 #  endif
 
diff --git a/libcxx/include/__ranges/concat_view.h b/libcxx/include/__ranges/concat_view.h
index 3bbe9db12e0f8..41fd8cd216c3f 100644
--- a/libcxx/include/__ranges/concat_view.h
+++ b/libcxx/include/__ranges/concat_view.h
@@ -289,9 +289,8 @@ class concat_view<_Views...>::__iterator : public __concat_view_iterator_categor
 
   template <typename _Func>
   _LIBCPP_HIDE_FROM_ABI constexpr auto __invoke_at_index(_Func&& __func) const {
-    // TODO(GCC 16): Just capture `this` when GCC PR113563 and PR121008 are fixed.
-    return [&__func, &__view_iter = *this]<std::size_t _Is>(this auto&& __self) {
-      if (_Is == __view_iter.__it_.index()) {
+    return [&__func, this]<std::size_t _Is>(this auto&& __self) {
+      if (_Is == __it_.index()) {
         return __func.template operator()<_Is>();
       }
       if constexpr (_Is + 1 < sizeof...(_Views)) {
diff --git a/libcxx/src/experimental/time_zone.cpp b/libcxx/src/experimental/time_zone.cpp
index fc7a9c26c91b2..8c7f24094003d 100644
--- a/libcxx/src/experimental/time_zone.cpp
+++ b/libcxx/src/experimental/time_zone.cpp
@@ -32,12 +32,6 @@
 // Work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120502
 
 #include <__config>
-
-// TODO(LLVM 23): When upgrading to GCC 16 this can be removed
-#ifdef _LIBCPP_COMPILER_GCC
-#  pragma GCC optimize("-O0")
-#endif
-
 #include <algorithm>
 #include <cctype>
 #include <chrono>
diff --git a/libcxx/test/libcxx/type_traits/desugars_to.compile.pass.cpp b/libcxx/test/libcxx/type_traits/desugars_to.compile.pass.cpp
index 9134ac027d1ed..af4e2c0d16d54 100644
--- a/libcxx/test/libcxx/type_traits/desugars_to.compile.pass.cpp
+++ b/libcxx/test/libcxx/type_traits/desugars_to.compile.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // This test requires variable templates
-// UNSUPPORTED: gcc && c++11
+// ADDITIONAL_COMPILE_FLAGS: -Wno-c++14-extensions
 
 #include <__type_traits/desugars_to.h>
 
diff --git a/libcxx/test/libcxx/utilities/function.objects/refwrap/desugars_to.compile.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/refwrap/desugars_to.compile.pass.cpp
index aa6bf85a1a40d..f76c266aa5a50 100644
--- a/libcxx/test/libcxx/utilities/function.objects/refwrap/desugars_to.compile.pass.cpp
+++ b/libcxx/test/libcxx/utilities/function.objects/refwrap/desugars_to.compile.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // This test requires variable templates
-// UNSUPPORTED: gcc && c++11
+// ADDITIONAL_COMPILE_FLAGS: -Wno-c++14-extensions
 
 // <functional>
 
diff --git a/libcxx/test/libcxx/utilities/meta/is_within_lifetime.verify.cpp b/libcxx/test/libcxx/utilities/meta/is_within_lifetime.verify.cpp
index 0aa0f226d63ca..7ed08ee0894a6 100644
--- a/libcxx/test/libcxx/utilities/meta/is_within_lifetime.verify.cpp
+++ b/libcxx/test/libcxx/utilities/meta/is_within_lifetime.verify.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
-// UNSUPPORTED: gcc-15
 
 // <type_traits>
 
diff --git a/libcxx/test/selftest/pass.cpp/werror.pass.cpp b/libcxx/test/selftest/pass.cpp/werror.pass.cpp
index 590785fc1774d..169f5ffef1172 100644
--- a/libcxx/test/selftest/pass.cpp/werror.pass.cpp
+++ b/libcxx/test/selftest/pass.cpp/werror.pass.cpp
@@ -14,9 +14,6 @@
 
 // ADDITIONAL_COMPILE_FLAGS: -Wunused-variable
 
-// TODO: We don't enable -Werror on GCC right now, because too many tests fail.
-// UNSUPPORTED: gcc
-
 int main(int, char**) {
     int foo;
 }
diff --git a/libcxx/test/selftest/sh.cpp/werror.sh.cpp b/libcxx/test/selftest/sh.cpp/werror.sh.cpp
index 3188f57ec8fd1..1863d2ebe57f3 100644
--- a/libcxx/test/selftest/sh.cpp/werror.sh.cpp
+++ b/libcxx/test/selftest/sh.cpp/werror.sh.cpp
@@ -11,9 +11,6 @@
 // Make sure that even a simple unused variable warning is treated as an
 // error in the test suite, including in .sh.cpp tests.
 
-// TODO: We don't enable -Werror on GCC right now, because too many tests fail.
-// UNSUPPORTED: gcc
-
 // RUN: %{build} -Wunused-variable
 // RUN: %{run}
 
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/try_emplace_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/try_emplace_transparent.pass.cpp
index 6a536d4d8282c..619b6e09ebccd 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/try_emplace_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/try_emplace_transparent.pass.cpp
@@ -7,8 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// gcc 15 ICE on this test
-// UNSUPPORTED: gcc
 
 // <flat_map>
 
diff --git a/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
index e7290aab2c661..4b1fc4214cbd6 100644
--- a/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
@@ -11,9 +11,6 @@
 // Even though <stdalign.h> is not provided by libc++,
 // we still test that using it with libc++ on the search path will work.
 
-// TODO: GCC doesn't provide a proper <stdalign.h> for C++ until 15.
-// UNSUPPORTED: gcc
-
 #include <stdalign.h>
 
 #ifndef __alignas_is_defined
diff --git a/libcxx/test/std/utilities/expected/expected.expected/monadic/transform.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/monadic/transform.pass.cpp
index 8f63d57af7dee..e1b3a373a7586 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/monadic/transform.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/monadic/transform.pass.cpp
@@ -10,7 +10,7 @@
 
 // GCC has a issue for `Guaranteed copy elision for potentially-overlapping non-static data members`,
 // please refer to: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98995
-// XFAIL: gcc-15
+// XFAIL: gcc-16
 
 // <expected>
 
diff --git a/libcxx/test/std/utilities/expected/expected.expected/monadic/transform_error.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/monadic/transform_error.pass.cpp
index babc813cdd2fe..ea91ee66b943f 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/monadic/transform_error.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/monadic/transform_error.pass.cpp
@@ -10,7 +10,7 @@
 
 // GCC has a issue for `Guaranteed copy elision for potentially-overlapping non-static data members`,
 // please refer to: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98995.
-// XFAIL: gcc-15
+// XFAIL: gcc-16
 
 // <expected>
 
diff --git a/libcxx/test/std/utilities/expected/expected.void/monadic/transform_error.pass.cpp b/libcxx/test/std/utilities/expected/expected.void/monadic/transform_error.pass.cpp
index f0ec946a053d9..b279a5b20fafa 100644
--- a/libcxx/test/std/utilities/expected/expected.void/monadic/transform_error.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.void/monadic/transform_error.pass.cpp
@@ -10,7 +10,7 @@
 
 // GCC has a issue for `Guaranteed copy elision for potentially-overlapping non-static data members`,
 // please refer to: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98995
-// XFAIL: gcc-15
+// XFAIL: gcc-16
 
 // <expected>
 
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
index 7c0499d091542..4038d91e0d950 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
@@ -8,7 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 // TODO FMT __builtin_memcpy isn't constexpr in GCC
-// UNSUPPORTED: gcc-15
+// UNSUPPORTED: gcc-16
 
 // <format>
 
diff --git a/libcxx/test/std/utilities/meta/meta.const.eval/is_within_lifetime.compile.pass.cpp b/libcxx/test/std/utilities/meta/meta.const.eval/is_within_lifetime.compile.pass.cpp
index f97b400f9a781..901e212938ffb 100644
--- a/libcxx/test/std/utilities/meta/meta.const.eval/is_within_lifetime.compile.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.const.eval/is_within_lifetime.compile.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
-// UNSUPPORTED: gcc-15
+// UNSUPPORTED: gcc-16
 
 // <type_traits>
 
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
index de91069713068..dcb5390971e44 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
@@ -8,9 +8,6 @@
 
 // REQUIRES: std-at-least-c++23
 
-// These compilers don't support __builtin_is_implicit_lifetime yet.
-// UNSUPPORTED: gcc-15
-
 // <type_traits>
 
 // template<class T> struct is_implicit_lifetime;
@@ -201,7 +198,9 @@ constexpr bool test() {
   test_is_implicit_lifetime<DeletedDestructorViaBaseInNonAggregate, false>();
 
   test_is_implicit_lifetime<ConstrainedUserDeclaredDefaultConstructor<true>, true>();
+#ifndef TEST_COMPILER_GCC // This is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126007
   test_is_implicit_lifetime<ConstrainedUserDeclaredDefaultConstructor<false>, false>();
+#endif
 
   test_is_implicit_lifetime<ConstrainedUserProvidedDestructor<true>, false>();
   test_is_implicit_lifetime<ConstrainedUserProvidedDestructor<false>, true>();
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
index 85336abdf6420..1a4229356ddbc 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
@@ -9,7 +9,7 @@
 // UNSUPPORTED: c++03
 
 // FIXME: Why does this start to fail with GCC 14?
-// XFAIL: !(c++11 || c++14) && gcc-15
+// XFAIL: !(c++11 || c++14) && gcc-16
 
 // See https://llvm.org/PR31384.
 



More information about the libcxx-commits mailing list