• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re: warning: control reaches end of non-void function when using @synchronized
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: warning: control reaches end of non-void function when using @synchronized


  • Subject: Re: Re: warning: control reaches end of non-void function when using @synchronized
  • From: "Shawn Erickson" <email@hidden>
  • Date: Thu, 7 Sep 2006 10:54:13 -0700

On 9/7/06, AgentM <email@hidden> wrote:

On Sep 7, 2006, at 13:17 , Shawn Erickson wrote:

> (...finally getting time to look into some minor issues I ran into
> over the last few months, anyway...)
>
> I use @synchronized in Objective-C++ built with Xcode 2.3 (using
> ggc-4.0 [1] and have objective-c exceptions enabled) and I get
> "warning: control reaches end of non-void function" when I specify
> -Wall for the following code.
>
> - (BlahParticipant*) getFirstOrganizer
> {
>    @synchronized (self) {
>        return [[firstOrganizer copy] autorelease];
>    }

You can't synchronize up the call stack. This is probably what you want:

- (BlahParticipant*) getFirstOrganizer
{
        id ret;
    @synchronized (self) {
        ret= [[firstOrganizer copy] autorelease];
    }
        return ret;
}

I don't understand your statement.

It is my understanding that @synchronized supports early exit from the
code block it wraps either because of an exception, return, goto,
break, etc. (just like its Java relative).

In other words the following is perfectly valid...

- (SomeObject*) someObject
{
   @synchronized (self) {
       ...do some work...

       if (foo == bar) {
           return foo;
       } else {
           ...
           @throw someException;
       }
   }

   return nil;
}

...and so should (but again I would get the warning that I don't think
I should be getting)...

- (SomeObject*) someObject
{
   @synchronized (self) {
       ...do some work...

       if (foo != bar) {
           ...
           @throw someException
       }

       return foo;
   }
}

-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >warning: control reaches end of non-void function when using @synchronized (From: "Shawn Erickson" <email@hidden>)
 >Re: warning: control reaches end of non-void function when using @synchronized (From: AgentM <email@hidden>)

  • Prev by Date: Re: Script to open file in Xcode at specific line number?
  • Next by Date: Re: Showing source code in Xcode 2.4 Debugger
  • Previous by thread: Re: warning: control reaches end of non-void function when using @synchronized
  • Next by thread: Re: warning: control reaches end of non-void function when using @synchronized
  • Index(es):
    • Date
    • Thread