public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Liviu Nicoara <lnicoara@thinkoid.org>
To: libc-alpha@sourceware.org
Cc: Liviu Nicoara <lnicoara@thinkoid.org>
Subject: [PATCH] <wchar.h>: Define __CORRECT_ISO_CPP_WCHAR_H_PROTO for Clang [BZ #34692]
Date: Tue, 29 Sep 2026 18:40:14 -0400	[thread overview]
Message-ID: <20260929224014.12925-1-lnicoara@thinkoid.org> (raw)

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


             reply	other threads:[~2026-09-29 22:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 22:40 Liviu Nicoara [this message]
2026-10-06 19:38 ` Adhemerval Zanella Netto
2026-10-07 12:12 ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929224014.12925-1-lnicoara@thinkoid.org \
    --to=lnicoara@thinkoid.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).