Re: [Linux-ia64] integer -> pointer question

Michael Madore
2000-07-31T23:16:08Z

Hi Dan,

> I can't see any *good* reason for storing integers into void pointers,
> if those integers aren't valid memory addresses.
>
> The C language definition requires a diagnostic in this case,
> regardless of any size issues and gcc emits this diagnostic even on
> x86, where the two types have the same size:
>
> ues12:~/tmp 68> cat test.c
> int main()
> {
> void *p = 123;
> return 0;
> }
> ues12:~/tmp 69> gcc test.c
> test.c: In function `main':
> test.c:3: warning: initialization makes pointer from integer without a cast
> ues12:~/tmp 70> uname -a
> Linux ues12 2.2.12-20 #1 Mon Sep 27 10:40:35 EDT 1999 i686 unknown
>
> If you want to shut up such warnings, do what gcc suggests: cast the
> integer to void *.

Sorry, my original post was a little unclear. The compiler spits out a
warning even if the programmer uses a cast.

Mike