[Bug objc++/35967] New: Local variables interpreted as volatile following a @try block

2008-04-17 Thread ymeroz at earthlink dot net
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



[Bug objc++/35967] Local variables interpreted as volatile following a @try block

2008-04-17 Thread ymeroz at earthlink dot net


--- Comment #2 from ymeroz at earthlink dot net  2008-04-17 23:41 ---
(In reply to comment #1)

 This is a side effect of how the next runtime implements their  
 exceptions.

This is a language syntax issue, as I see it. Variable type can not change by
itself in mid-scope in C++ or Obj-C. This is not an issue of runtime
implementation.


-- 


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