Re: winedump: Cast-qual warnings fix
Andrew Talbot <Andrew.Talbot(a)talbotville.com> writes:
+ const char *iter, *base_type, *catch_unsigned; + union + { + const char *constant; + char *nonconst; + } type_str;
That's not better than simply casting const away, it's just hiding the problem from the compiler. -- Alexandre Julliard julliard(a)winehq.org
On Fri, Jul 13, 2007 at 12:29:36PM +0200, Alexandre Julliard wrote:
Andrew Talbot <Andrew.Talbot(a)talbotville.com> writes:
+ const char *iter, *base_type, *catch_unsigned; + union + { + const char *constant; + char *nonconst; + } type_str;
That's not better than simply casting const away, it's just hiding the problem from the compiler.
And I'm not sure that the compiler is required to treat the two fields of the union as being the same data item. Certainly if the fields of the union are 'void *' and 'intptr_t' you can't assume that a value written to one field of the union can be immediately read from the other. David -- David Laight: david(a)l8s.co.uk
David Laight wrote:
And I'm not sure that the compiler is required to treat the two fields of the union as being the same data item. Certainly if the fields of the union are 'void *' and 'intptr_t' you can't assume that a value written to one field of the union can be immediately read from the other.
David
My guess is that one cannot swap between different types (void * and intptr_t, being a pointer type and an integer type, respectively), but I would be inclined to think that char * and const char * do not differ in type, only in qualifier, so perhaps one could, in that case. However, I still have to consign this technique to the reject pile of those that do not make the grade. -- Andy.
participants (3)
-
Alexandre Julliard -
Andrew Talbot -
David Laight