Re: Feature request: gcc should warn upon conversions ptrdiff_t -> int
[gcc-gnats@gcc.gnu.org removed; no bug was added to the gcc database,
since the email was malformed]
On Tue, Jun 10, 2003 at 10:32:09PM -0400, Matteo Frigo wrote:
> >Description:
>
> It would be nice if this function issued a warning because of the
> implicit conversion ptrdiff_t -> int:
>
> int foo(int *x, int *y)
> {
> return x - y;
> }
There is no conversion to int. foo* may be subtracted from foo* for any
type foo. It's normal pointer arithmetic. This code is fine.
> This code is correct on 32-bit machines, but it is likely to be wrong
> on machines with 64-bit pointers and 32-bit integers. If possible,
> the warning should be issued on 32-bit machines, too, to help prevent
> future problems.
Pointers can be 42.69 bits wide, and the code would still be correct.
Reply to: