-Wold-style-casts and system headers
Anthony Foiani
tkil@scrye.com
Tue Jun 18 16:57:00 GMT 2013
Jonathan --
Thanks for the quick reply.
Jonathan Wakely <jwakely.gcc@gmail.com> writes:
> On 18 June 2013 17:14, Anthony Foiani wrote:
>> I'm aware that I can disable that warning for the single file, or even
>> for a single region in the file using pragmas, but I would like to
>> understand why g++ isn't applying the "system header" rule to that
>> macro.
>
> It's because the expansion of the macro is in your code, not in a
> system header.
If that's the expected behavior, then the manual probably needs
rephrasing:
"Macros defined in a system header are immune to a few warnings
wherever they are expanded."
I certainly expected "wherever" to include user code, and it seems
that's an important place for it to apply. An even shorter example:
#include <sys/select.h>
int main()
{
fd_set fds;
FD_CLR( 0, &fds );
return 0;
}
Generates:
$ g++ -Wold-style-cast -o g++-cast-warning g++-cast-warning.cpp
g++-cast-warning.cpp: In function ‘int main()’:
g++-cast-warning.cpp:47:5: warning: use of old-style cast [-Wold-style-cast]
g++-cast-warning.cpp:47:5: warning: use of old-style cast [-Wold-style-cast]
g++-cast-warning.cpp:47:5: warning: use of old-style cast [-Wold-style-cast]
> There are some open bug reports on similar subjects
> e.g. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7263#c8
From a quick read, it seems that the infrastructure to fix this
problem is in 4.8, but this particular problem isn't fixed?
Should I file another PR?
Thanks again,
Anthony Foiani
More information about the Gcc-help
mailing list