[PATCH] <wchar.h>: Define __CORRECT_ISO_CPP_WCHAR_H_PROTO for Clang [BZ #34692]
Liviu Nicoara
lnicoara@thinkoid.org
Tue Sep 29 22:40:14 GMT 2026
Without the asm redirects, wcschr et al. are not const-correct.
Commit 953ceff17a4a15b10cfdd5edc3c8cae4884c8ec3 widened the guard of
__CORRECT_ISO_CPP_STRING_H_PROTO in <string.h> to Clang 3.5 and later
[BZ #25232]. <wchar.h> kept the guard it had since 2009, so under
Clang with libstdc++ or with just the C headers, wcschr, wcspbrk,
wcsrchr, wcsstr, wcswcs and wmemchr have only the C prototype. A
const wchar_t * argument then yields a wchar_t * result without a
diagnostic.
This change applies the <string.h> condition to <wchar.h>. It does
not impact GCC.
Checked on x86_64-linux-gnu with GCC 16.2.1 and Clang 22.1.8.
Signed-off-by: Liviu Nicoara <lnicoara@thinkoid.org>
---
wcsmbs/wchar.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 4709c210fb..ba5a884a40 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -65,7 +65,8 @@ typedef __gnuc_va_list va_list;
#endif
/* Tell the caller that we provide correct C++ prototypes. */
-#if defined __cplusplus && __GNUC_PREREQ (4, 4)
+#if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
+ || __glibc_clang_prereq (3, 5))
# define __CORRECT_ISO_CPP_WCHAR_H_PROTO
#endif
--
2.55.0
More information about the Libc-alpha
mailing list