[PATCH] aliasing warning in ctype.h
Ian Wienand
ianw@gelato.unsw.edu.au
Thu Mar 20 23:41:00 GMT 2003
Hello,
The attached patch removes warning like :
../include/ctype.h:38: warning: dereferencing type-punned pointer will
break strict-aliasing rules
from ctype.h
2003-03-21 Ian Wienand <ianw@gelato.unsw.edu.au>
* include/ctype.h : don't cast results of __libc_tsd_address
to avoid pointer aliasing warning.
-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au
-------------- next part --------------
--- include/ctype.h.orig 2003-03-21 10:28:48.000000000 +1100
+++ include/ctype.h 2003-03-21 10:27:40.000000000 +1100
@@ -25,31 +25,28 @@
CTYPE_EXTERN_INLINE const uint16_t ** __attribute__ ((const))
__ctype_b_loc (void)
{
- const uint16_t **tablep =
- (const uint16_t **) __libc_tsd_address (CTYPE_B);
+ void **tablep = __libc_tsd_address (CTYPE_B);
if (__builtin_expect (*tablep == NULL, 0))
- *tablep = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128;
- return tablep;
+ *tablep = ((void *)(_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128));
+ return ((const uint16_t **)tablep);
}
CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const))
__ctype_toupper_loc (void)
{
- const int32_t **tablep =
- (const int32_t **) __libc_tsd_address (CTYPE_TOUPPER);
+ void **tablep = __libc_tsd_address (CTYPE_TOUPPER);
if (__builtin_expect (*tablep == NULL, 0))
- *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
- return tablep;
+ *tablep = ((void *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
+ return ((const int32_t **)tablep);
}
CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const))
__ctype_tolower_loc (void)
{
- const int32_t **tablep =
- (const int32_t **) __libc_tsd_address (CTYPE_TOLOWER);
+ void **tablep = __libc_tsd_address (CTYPE_TOLOWER);
if (__builtin_expect (*tablep == NULL, 0))
- *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
- return tablep;
+ *tablep = ((void *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
+ return ((const int32_t **)tablep);
}
# endif /* Not NOT_IN_libc. */
More information about the Libc-alpha
mailing list