Re: Wide-string Functions: Double Casting

2006-08-12 Thread Eric Pouech
David Laight wrote: On Tue, Aug 08, 2006 at 09:27:23PM +0200, Eric Pouech wrote: what I don't like is that in order to plug a hole (casting from const foo* to foo*), we create a bigger hole by allowing to cast from const foo* to bar* (and the compiler will not give any warning) if we want

Re: Wide-string Functions: Double Casting

2006-08-12 Thread Andrew Talbot
Once qualifications are give, how hard it is to take them away, again! Of course, if one were realising these small inline functions literally as inline code, one would not add a const qualification for a few lines, only to take it away again (with great difficulty). Thus, one would not write:

Re: Wide-string Functions: Double Casting

2006-08-08 Thread Marcus Meissner
On Mon, Aug 07, 2006 at 09:54:20PM +0100, Andrew Talbot wrote: Although I accept that my opinion may not be universally shared :-), I believe that it is better to turn -Wcast-qual on permanently and double-cast the appropriate return values of the relevant wide-string functions (strchrW(),

Re: Wide-string Functions: Double Casting

2006-08-08 Thread Andrew Talbot
Marcus Meissner wrote: I asked our gcc gurus. - If you want to cast, do not use size_t but uintptr_t. Or: - Do not inline the function, and compile its file without -Wcast-qual. - Fix the prototype to read extern inline const WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) Ciao,

Re: Wide-string Functions: Double Casting

2006-08-08 Thread Eric Pouech
Andrew Talbot wrote: David Laight wrote: On Mon, Aug 07, 2006 at 09:54:20PM +0100, Andrew Talbot wrote: would like to submit a patch that, for example, changes strchrW() to: extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) { WCHAR *ret = NULL; do { if (*str == ch)

Re: Wide-string Functions: Double Casting

2006-08-08 Thread David Laight
On Tue, Aug 08, 2006 at 09:27:23PM +0200, Eric Pouech wrote: what I don't like is that in order to plug a hole (casting from const foo* to foo*), we create a bigger hole by allowing to cast from const foo* to bar* (and the compiler will not give any warning) if we want to go into this, then

Wide-string Functions: Double Casting

2006-08-07 Thread Andrew Talbot
Although I accept that my opinion may not be universally shared :-), I believe that it is better to turn -Wcast-qual on permanently and double-cast the appropriate return values of the relevant wide-string functions (strchrW(), strrchrW(), strpbrkW(), memchrW() and memrchrW()) than to leave it

Re: Wide-string Functions: Double Casting

2006-08-07 Thread Andrew Talbot
Andrew Talbot wrote: [...] So I would like to submit a patch that, for example, changes strchrW() to: extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) [...] Yes, that was a typo: it should say changes strrchrW() -- Andy.

Re: Wide-string Functions: Double Casting

2006-08-07 Thread David Laight
On Mon, Aug 07, 2006 at 09:54:20PM +0100, Andrew Talbot wrote: would like to submit a patch that, for example, changes strchrW() to: extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) { WCHAR *ret = NULL; do { if (*str == ch) ret = (WCHAR *)(size_t)str; } while (*str++);

Re: Wide-string Functions: Double Casting

2006-08-07 Thread Andrew Talbot
David Laight wrote: On Mon, Aug 07, 2006 at 09:54:20PM +0100, Andrew Talbot wrote: would like to submit a patch that, for example, changes strchrW() to: extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) { WCHAR *ret = NULL; do { if (*str == ch) ret = (WCHAR