GCC compiler -- bug or unspecified behavior?
Posted
by Jared P
on Stack Overflow
See other posts from Stack Overflow
or by Jared P
Published on 2010-05-12T16:32:25Z
Indexed on
2010/05/12
16:34 UTC
Read the original article
Hit count: 157
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.)
© Stack Overflow or respective owner