This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] aliasing warning in ctype.h
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ian Wienand <ianw at gelato dot unsw dot edu dot au>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Fri, 21 Mar 2003 00:52:14 +0100
- Subject: Re: [PATCH] aliasing warning in ctype.h
- References: <20030320234057.GA17072@cse.unsw.edu.au>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Mar 21, 2003 at 10:40:57AM +1100, Ian Wienand wrote:
> --- 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);
> }
This is wrong, although you shut up a warning, you actually create
code which (unlike original) does the illegal type punning
(and thus the compiler might/will miscompile it).
Jakub