[llvm-commits] [compiler-rt] r82605 - /compiler-rt/trunk/BlocksRuntime/runtime.c

Shantonu Sen ssen at apple.com
Wed Sep 23 10:18:30 CDT 2009


compiler-rt builds with -pedantic, and on Linux with gcc 4.3.3 the  
original code got:
#include <stdio.h>
#include <stdint.h>

int main(int argc, char *argv[]) {
   printf("%p\n", main);
   return 0;
}

ssen at ssen:~$ cc -o main main.c -Wall -Os -std=c99 -pedantic
main.c: In function ‘main’:
main.c:4: warning: format ‘%p’ expects type ‘void *’, but argument 2  
has type ‘int (*)(int,  char **)’

If I added a (void *) cast I got:
ssen at ssen:~$ cc -o main main.c -Wall -Os -std=c99 -pedantic
main.c: In function ‘main’:
main.c:4: warning: ISO C forbids conversion of function pointer to  
object pointer type

I guess you could really bludgeon this code to death with (void *) 
(uintptr_t), but this seems kind of absurd, so I stopped short of  
that... Maybe that's what we want, since it is logically an address...

Shantonu

Sent from my MacBook

On Sep 23, 2009, at 5:12 AM, Edward O'Callaghan wrote:

> I must confess to not looking at the context and fixing this at  
> around 5am.
>
> 2009/9/23 John McCall <rjmccall at apple.com>:
>> Daniel Dunbar wrote:
>>
>> Hi Edward,
>>
>> On Tue, Sep 22, 2009 at 8:47 PM, Edward O'Callaghan
>> <eocallaghan at auroraux.org> wrote:
>>
>>
>> Author: evocallaghan
>> Date: Tue Sep 22 22:47:24 2009
>> New Revision: 82605
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=82605&view=rev
>> Log:
>> Fix compile time warning: format '%#lx' expects type 'long unsigned  
>> int',
>> but argument 3 has type 'unsigned int'
>>
>>
>> This isn't correct (of course, neither was the original). Argument 3
>> has type uintptr_t, which is not necessarily unsigned int. To be more
>> painfully portable it should probably always print as a uint64_t (I
>> confess to not looking at the context).
>>
>> Is there a problem preventing us from using %p to display these  
>> pointer
>> values instead of hacking together our own equivalent?
>>
>> John.
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
>
>
>
> -- 
> -- 
> Edward O'Callaghan
> http://www.auroraux.org/
> eocallaghan at auroraux dot org
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list