Nat! bio photo


Senior Mull

Twitter Github Twitch

gcc selector warning, annoying and wrong

Run this convenient shell script:
# Mulle kybernetiK 2011, coded by Nat!

cat <<EOF > /tmp/x.m  

@interface X 

+ (void *) z;


@interface Y : X

+ (void *) y;


@implementation Y

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


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 :(