Re: Useless pointer-to-int-cast warning?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Aug 20, 2018 at 10:05:57AM +0200, Vincent Lefevre wrote:
> On 2018-08-18 14:19:10 -0500, Segher Boessenkool wrote:
> > Usually cast between a pointer type and a different size integer type
> > is a programmer mistake.  That is why this warning is enabled by -Wall.
> 
> I don't see why. In doubt, one should be able to choose the largest
> integer type available. Note also that the C standard does not say
> that an integer type of the same size as the pointer is sufficient.

In the infrequent case where you do want to cast a pointer to an integer
and back, you should use uintptr_t.  It's what it is there for!

("But it is optional!"  It is required by susv3, most systems have it).

> > Do you have evidence of many false positives?
> 
> False positives when casting to uintmax_t.

That's not what I asked: do people actually see many false positives?
If that was true, bugzilla should be filled with it by now.


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux