This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] aliasing warning in ctype.h


On Fri, Mar 21, 2003 at 11:13:27AM +1100, Paul Mackerras wrote:
> Jakub Jelinek writes:
> 
> > 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).
> 
> So you're saying that gcc will warn on code which is actually OK, but
> won't warn on code that is actually broken?  Great. :(

Sadly that's true.
The code gcc warns about always accesses that word of memory using
a const uint16_t ** pointer which is ok from the standard point of view.
GCC cannot know though if you don't access the same piece of memory
somewhere using the declared type.
The code in the patch Ian posted compares that word of memory with NULL
using void ** pointer, stores it through that pointer if it was NULL
too, but then reads through that pointer using const uint16_t ** pointer
(this is already not in __ctype_b_loc, but in the function
which inlines it; e.g. isctype does
((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)
).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]