httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rüdiger Plüm <r.pl...@gmx.de>
Subject Re: svn commit: r293305 - in /httpd/httpd/branches/2.2.x/modules:
Date Tue, 04 Oct 2005 20:04:14 GMT


On 10/04/2005 09:32 PM, William A. Rowe, Jr. wrote:
> Brian Candler wrote:
> 

[..cut..]

> 
>> P.S. The reverse case is sillier, given that the value is moving to a
>> *larger* type and therefore no data loss can occur:
>>
>>     short a;
>>     long b = a;          // (7) no warning
>>
>>     short a;
>>     void *b = a;         // (8) warns "pointer from integer without a
>> cast" (ok)
>>     void *c = (void *)a; // (9) warns "cast to pointer from integer of
>> different size"
>>     void *d = (void *)(long)a;  // (10) even more stupid!!!
>>
>> Note that having a 'large enough' integral type in case (10) is not good
>> enough. We need to cast 'a' to an integral type which is *exactly* the
>> same
>> size as a void *, to silence this particular warning.
> 
> 
> I agree with your assertion that the code example above IS a gcc bug.
> This is expected in C++, but the waning (9) above is completely bogus,

I do not think so. While "a" does fit in "c" from the storage point of view
converting "c" to a different pointer type e.g. (char *) and dereferencing it
afterwards most likely leads to SIGBUS or SIGSEGV. So I think a warning is
justified here.

> as you illustrate with line (7) above.
> 

This is different as no harm can be expected here like in (9).

[..cut..]

Regards

Rüdiger

Mime
View raw message