can't disable pointer-to-int-cast warnings

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

 



Hi,

We need to selectively disable int-to-pointer-cast warnings in pragmas, but these particular classes of warnings appear to be invulnerable to disabling. The following code:

#include <inttypes.h>
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"

void f(intptr_t x)
{
                (void)x;
}

int main(void)
{
                char name[] = "bob";
                f(name);
}

Compiled with this commandline:
gcc -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -c foo.c

produces the following (approximate) output with GCC 4.3.5, 4.4.4, 4.5.1, and 4.6 RC2, regardless of optimization level:
foo.c: In function 'main':
foo.c:13:2: warning: passing argument 1 of 'f' makes integer from pointer without a cast [enabled by default]
foo.c:5:6: note: expected 'intptr_t' but argument is of type 'char *'


Trying the pragmas by themselves doesn’t disable the warnings, nor the commandline parameters by themselves, nor the both of them together. 

This is obviously a bug, which I will file on Monday, but we are really hoping for a workaround that is embeddable into the header file of our library.

Thanks in advance!



[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