GCC compiler -- bug or unspecified behavior?
- by Jared P
When I have conflicting definitions of the ivars of a class in objective-c (not redeclaring the class in the same file, but rather naming the same class with diff ivars, no warnings or better yet errors are issued by the compiler. However, both sets of ivars are useable by the appropriate methods in the respective files. For instance
Foo.m:
@interface foo {
int a;
}
- (int)method;
@end
@implementation foo
- (int)method {
return a;
}
@end
Bar.m:
@interface foo {
float baz;
}
@end
@implementation foo (category)
- (float)blah {
return baz;
}
@end
compiles without warnings or errors. Is this intentional? Is this an unchecked error? (for the record, a and baz are actually the same memory location.)