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

           Summary: unused-but-set-variabled warning when using fast
                    enumeration
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: objc
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: j...@kuijpersvof.nl


When setting a variable and enumerating through it using fast enumeration, the
compiler does not see it as usage of the variable. Using -Wall gives a warning:

$ objfw-compile -Wall -o fetest fetest.m
fetest.m: In function â-[test applicationDidFinishLaunching]â:
fetest.m:11:11: warning: variable âarrâ set but not used
[-Wunused-but-set-variable]

$ ./fetest
[2011-02-10 17:43:35.021 fetest(22073)] Item: Foo
[2011-02-10 17:43:35.022 fetest(22073)] Item: Bar

$ cat fetest.m
#import <ObjFW/ObjFW.h>

@interface test : OFObject @end

OF_APPLICATION_DELEGATE(test)

@implementation test

- (void)applicationDidFinishLaunching
{
        OFArray *arr;
        arr = [OFArray arrayWithObjects:@"Foo",@"Bar",nil];

        for(OFString *str in arr)
        {
                of_log(@"Item: %@",str);
        }
}

@end


$ gcc-4.6 -v
Using built-in specs.
COLLECT_GCC=gcc-4.6
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --disable-multilib --program-suffix=-4.6
--prefix=/usr/local/ --enable-languages=c,c++,objc,obj-c++ --enable-threads
Thread model: posix
gcc version 4.6.0 20101219 (experimental) (GCC)

Reply via email to