| Message ID | 20260929224014.12925-1-lnicoara@thinkoid.org |
|---|---|
| State | New |
| Headers | show |
| Series | <wchar.h>: Define __CORRECT_ISO_CPP_WCHAR_H_PROTO for Clang [BZ #34692] | expand |
On 30/09/26 00:40, Liviu Nicoara wrote: > 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> LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.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 >
On 30/09/26 00:40, Liviu Nicoara wrote: > 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> LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.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 >
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
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(-)