Test case: ----------------- start file bug.mm @interface TestClass -(void) testMethod; @end
void ff (int& i) { } @implementation TestClass -(void) testMethod { int i = 1; int& iref = i; @try {} @catch (id) {} @finally {} ff (i); // Bug ff (iref); // OK } @end ----------------- end file gcc --version i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5370) gcc-4.0 -x objective-c++ -fobjc-exceptions -c bug.mm bug.mm: In function 'void -[TestClass testMethod](TestClass*, objc_selector*)': bug.mm:23: error: invalid initialization of reference of type 'int&' from expression of type 'volatile int' bug.mm:5: error: in passing argument 1 of 'void ff(int&)' Summary: Adding Obj-C try/catch/finally blocks causes i to be considered volatile afterwards. Workaround: Create a reference to i and use that instead. -- Summary: Local variables interpreted as volatile following a @try block Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: objc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ymeroz at earthlink dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35967