This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug objc/77428] New: incorrect 'set but not used' warning with @throw
- From: "vries at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 31 Aug 2016 18:33:32 +0000
- Subject: [Bug objc/77428] New: incorrect 'set but not used' warning with @throw
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77428
Bug ID: 77428
Summary: incorrect 'set but not used' warning with @throw
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: objc
Assignee: unassigned at gcc dot gnu.org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
test.m:
...
#import <objc/Object.h>
#import <stdio.h>
void
foo2 (void)
{
printf ("foo2\n");
}
int
main (void)
{
id o = nil;
@try {
printf ("before throw\n");
@throw o;
printf ("after throw\n");
} @catch (id ue) {
if (ue != nil)
foo2 ();
else
printf ("not foo2\n");
}
return 0;
}
...
$ gcc test.m -fobjc-exceptions -lobjc -Wall:
...
test.m: In function ‘main’:
test.m:13:6: warning: variable ‘o’ set but not used [-Wunused-but-set-variable]
id o = nil;
^
...
The warning is incorrect, variable 'o' is in fact used by @throw.