[libcxx-commits] [libcxx] [libc++] Remove `noexcept` from `format_context::arg` method (PR #205809)

David Bayer via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 25 06:05:15 PDT 2026


https://github.com/davebayer created https://github.com/llvm/llvm-project/pull/205809

The `format_context` specialization for `__retarget_buffer` has the `arg` method marked as `noexcept`. However, the function pointer that it invokes throws exceptions which can cause in unwanted abortion of the program.

This PR removes the `noexcept` specifier from this method.

>From 5f8945248057b7ea48fe3fe6deebe28fcaf456f1 Mon Sep 17 00:00:00 2001
From: David Bayer <bayer.david99 at gmail.com>
Date: Thu, 25 Jun 2026 15:00:09 +0200
Subject: [PATCH] [libc++] Remove `noexcept` from `format_context::arg` method

---
 libcxx/include/__format/format_context.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h
index cf3131b80e52f..a7064ed8c4bab 100644
--- a/libcxx/include/__format/format_context.h
+++ b/libcxx/include/__format/format_context.h
@@ -182,7 +182,7 @@ class basic_format_context<typename __format::__retarget_buffer<_CharT>::__itera
         }) {
   }
 
-  _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {
+  _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const {
     return __arg_(__ctx_, __id);
   }
 #  if _LIBCPP_HAS_LOCALIZATION



More information about the libcxx-commits mailing list