Nat! bio photo

Nat!

Senior Mull.

Twitter RSS

Github

gcc selector warning, annoying and wrong

Run this convenient shell script:

script.sh
#!/bin/sh 
#
# Mulle kybernetiK 2011, coded by Nat!

cat <<EOF > /tmp/x.m  

@interface X 
{
}

+ (void *) z;

@end


@interface Y : X
{
}

+ (void *) y;

@end


@implementation Y

+ (void *) y
{
   return( [self z]);
}

@end
EOF

gcc -Wselector -c /tmp/x.m 

it will produce the following output:

x.m:25: warning: creating selector for nonexistent method 'z'

But why ? This looks like an obvious bug in gcc. First of all this warning shouldn't be emitted by -Wselector but by -Wundeclared-selector instead. And then of course the warning is wrong :(