[Bug objc/56044] New: Add dialect option to gobjc to prevent instance variables from posing as local variables inside methods.

dpapavas at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jan 19 11:09:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56044

             Bug #: 56044
           Summary: Add dialect option to gobjc to prevent instance
                    variables from posing as local variables inside
                    methods.
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: objc
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dpapavas@gmail.com


Class instance variables in Objective-C can be accessed as if they were local
variables (without self->) inside class methods which luckily can be avoided
simply by not using the feature.  The only problem is that in that case you're
prevented from using an actual local variable or method argument with the same
name.  This can often be useful for instance in cases such as these:

-(SomeOmbject *)initWithBuffer: (char *buffer)
{
    [super init];
    self->buffer = buffer;

    return self;
}

In this case the compile would warn about variable shadowing and to avoid that
you have to find some other name for the variable which can get annoying.  It
would be nice therefore if this feature could be disabled for those that do not
like to use it.



More information about the Gcc-bugs mailing list