This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi!
Doing:
#include <wchar.h>
void *p = (void *) btowc;
at -O1+ in C++ (or similarly if for whatever reason the inline isn't always
inlined) results in endless recursion:
.section .text.btowc,"axG",@progbits,btowc,comdat
.align 2
.p2align 4,,15
.weak btowc
.type btowc, @function
btowc:
jmp btowc
.size btowc, .-btowc
The optimization really relies on the GNU C extern inline behavior.
We use the same __*_alias trick in plenty of the _FORTIFY_SOURCE headers,
but none of them is used for C++ nor for non-GCC compilers.
__USE_EXTERN_INLINES implies GCC 2.7+, so we just need to check for C++.
2006-03-27 Jakub Jelinek <jakub@redhat.com>
* wcsmbs/wchar.h (btowc, wctob): Don't optimize in C++.
--- libc/wcsmbs/wchar.h.jj 2006-03-17 08:37:07.000000000 +0100
+++ libc/wcsmbs/wchar.h 2006-03-27 18:38:07.000000000 +0200
@@ -321,6 +321,7 @@ __END_NAMESPACE_C99
#ifdef __USE_EXTERN_INLINES
/* Define inline function as optimization. */
+# ifndef __cplusplus
/* We can use the BTOWC and WCTOB optimizations since we know that all
locales must use ASCII encoding for the values in the ASCII range
and because the wchar_t encoding is always ISO 10646. */
@@ -335,6 +336,7 @@ extern __inline int
__NTH (wctob (wint_t __wc))
{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
? (int) __wc : __wctob_alias (__wc)); }
+# endif
extern __inline size_t
__NTH (mbrlen (__const char *__restrict __s, size_t __n,
Jakub
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |