http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48539
Summary: Missing warning when messaging a forward-declared class Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: objc AssignedTo: unassig...@gcc.gnu.org ReportedBy: nic...@gcc.gnu.org The following testcase compiles with no warnings on GCC 4.7.0 20110326: #include <objc/objc.h> @class A; @interface B { id isa; } + (void) doSomething; @end void test (void) { [A doSomething]; } While clang produces a hard error: z.m:14:4: warning: receiver 'A' is a forward class and corresponding @interface may not exist [A doSomething]; ^ z.m:9:1: note: method 'doSomething' is used for the forward class + (void) doSomething; ^ 1 warning generated. In this case, the behaviour of clang seems better. @class is really meant to resolve recursive declarations; it should always be followed by the corresponding @interface, particularly if you are going to message the class or objects of the class. I would say that GCC should produce at least a warning in this case! There's also the issue of whether the following testcase should also produce a warning: #include <objc/objc.h> @class A; @interface B { id isa; } - (void) doSomething; @end void test (A *x) { [x doSomething]; } This is slightly different in that it is an instance message, as opposed to a class message. Neither GCC nor clang produce any warning or error here, but it sounds like a warning similar to the one above would be very appropriate. Thanks