[libcxx-commits] [libcxx] AIX fopen() does not support the 'x' (exclusive/noreplace) mode suffix. (PR #206498)
Jake Egan via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 3 09:45:00 PDT 2026
================
@@ -645,6 +634,15 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _
case ios_base::in | ios_base::app | ios_base::binary:
return "a+b" _LIBCPP_FOPEN_CLOEXEC_MODE;
# if _LIBCPP_STD_VER >= 23
+// AIX fopen() does not support the 'x' (exclusive/noreplace) mode suffix, so these
+// cases are omitted on AIX and fall through to default (return nullptr), signalling
+// failure to the caller. This is conformant: C23 (7.21.5.3p5), which C++ relies on
+// by proxy, requires that if the implementation cannot atomically check for the
+// existence of the file and create it, it shall fail rather than perform a
+// non-atomic check and creation. Since AIX cannot provide atomic exclusive-open
+// semantics via fopen(), returning nullptr is the correct behaviour.
+// _AIX is defined by clang on AIX; __TOS_AIX__ is defined by both clang and XLC.
----------------
jakeegan wrote:
`__TOS_AIX__` isn't necessary. Open XL defines `_AIX`.
https://github.com/llvm/llvm-project/pull/206498
More information about the libcxx-commits
mailing list