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

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

 



On Mon, 20 Aug 2018 at 09:07, 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.

It says even uintmax_t might not be sufficient. It also says that if
intptr_t and uintptr_t are defined, then they can hold the value of
any void*.

So it seems like you're not actually solving the problem by using
uintmax_t, just reducing it. I still think it's best to use uintptr_t
when available.



[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