about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2003-07-29 23:48:35 +0000
committerRoland McGrath <roland@gnu.org>2003-07-29 23:48:35 +0000
commit0d2f48bb4a25495bbb44ab4ef3a9a545cdc19359 (patch)
tree110e38214162147ace4c97dc7834c78cc3a5ff47
parent98c24a32e60751a02e33e08f7069dd7725c51fd4 (diff)
downloadglibc-0d2f48bb4a25495bbb44ab4ef3a9a545cdc19359.tar.gz
glibc-0d2f48bb4a25495bbb44ab4ef3a9a545cdc19359.tar.xz
glibc-0d2f48bb4a25495bbb44ab4ef3a9a545cdc19359.zip
* include/ctype.h (__ctype_b_loc, __ctype_toupper_loc,
	__ctype_tolower_loc): Avoid "dereferencing type-punned pointer will
	break strict-aliasing rules" warnings.
-rw-r--r--ChangeLog6
-rw-r--r--include/ctype.h42
2 files changed, 33 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index a3c483363c..79716fa928 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-29  Jakub Jelinek  <jakub@redhat.com>
+
+	* include/ctype.h (__ctype_b_loc, __ctype_toupper_loc,
+	__ctype_tolower_loc): Avoid "dereferencing type-punned pointer will
+	break strict-aliasing rules" warnings.
+
 2003-07-29  Roland McGrath  <roland@redhat.com>
 
 	* elf/Makefile: Revert accidental changes in last commit.
diff --git a/include/ctype.h b/include/ctype.h
index ca3c3dd856..4896d14f17 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -25,31 +25,43 @@ __libc_tsd_define (extern, CTYPE_TOLOWER)
 CTYPE_EXTERN_INLINE const uint16_t ** __attribute__ ((const))
 __ctype_b_loc (void)
 {
-  const uint16_t **tablep =
-    (const uint16_t **) __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;
+  union
+    {
+      void **ptr;
+      const uint16_t **tablep;
+    } u;
+  u.ptr = __libc_tsd_address (CTYPE_B);
+  if (__builtin_expect (*u.tablep == NULL, 0))
+    *u.tablep = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128;
+  return u.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);
-  if (__builtin_expect (*tablep == NULL, 0))
-    *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
-  return tablep;
+  union
+    {
+      void **ptr;
+      const int32_t **tablep;
+    } u;
+  u.ptr = __libc_tsd_address (CTYPE_TOUPPER);
+  if (__builtin_expect (*u.tablep == NULL, 0))
+    *u.tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
+  return u.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);
-  if (__builtin_expect (*tablep == NULL, 0))
-    *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
-  return tablep;
+  union
+    {
+      void **ptr;
+      const int32_t **tablep;
+    } u;
+  u.ptr = __libc_tsd_address (CTYPE_TOLOWER);
+  if (__builtin_expect (*u.tablep == NULL, 0))
+    *u.tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
+  return u.tablep;
 }
 
 # endif	/* Not NOT_IN_libc.  */