• 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: Arc: Switch case is in protected scope
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arc: Switch case is in protected scope


  • Subject: Re: Arc: Switch case is in protected scope
  • From: Sean McBride <email@hidden>
  • Date: Tue, 22 Oct 2013 11:50:58 -0400
  • Organization: Rogue Research Inc.

On Tue, 22 Oct 2013 10:31:01 +0200, Daniel Höpfl said:

>> Was the old (non-arc) code faulty (but the compiler did not notice
>> this)?
>> Why is the arc-version (with TRIGGER_ERROR defined) wrong?
>
>It is wrong in the non-arc world, too. (ISO/IEC 9899:2011 AKA C11,
>6.8.6.1: "A goto statement shall not jump from outside the scope of an
>identifier having a variably modified type to inside the scope of that
>identifier" - switch is a special case of goto.)

Daniel,

I don't think you can quote the Standard about 'goto' and just wave your hands and say it applies to 'switch' also.  :)  The Standard's description of 'switch' should contain the answer.

However, it does seem to me there is a clang bug here somewhere.

I've made a shorter compilable example:

----------------------
#import <Foundation/Foundation.h>

int main (void)
{
	int x = 0;
	switch(x)
	{
		case 1:
			x++;
#if 0 // toggle me
			NSObject* foo = nil;
#else
			int* foo = 0;
#endif
			(void)foo;
			break;

		default:
			x++;
	};

	return 0;
}
----------------------

Then build with both:
$ xcrun clang -fsyntax-only -Weverything test.m
$ xcrun clang -fsyntax-only -Weverything -fobjc-arc test.m

If 'foo' is int*, clang has no complaints in non-ARC and ARC.

If 'foo' is NSObject*, clang has no complaints in non-ARC, but errors in ARC.

IMHO, that's pretty weird!

The only bug I can find in llvm bugzilla that looks related was fixed years ago:
<http://llvm.org/PR7789>

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Arc: Switch case is in protected scope
      • From: Daniel Höpfl <email@hidden>
    • Re: Arc: Switch case is in protected scope
      • From: "Clark S. Cox III" <email@hidden>
    • Re: Arc: Switch case is in protected scope
      • From: Scott Ribe <email@hidden>
References: 
 >Arc: Switch case is in protected scope (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Arc: Switch case is in protected scope (From: Daniel Höpfl <email@hidden>)

  • Prev by Date: Re: How to change highlight colour on NSTableView row
  • Next by Date: Re: Arc: Switch case is in protected scope
  • Previous by thread: Re: Arc: Switch case is in protected scope
  • Next by thread: Re: Arc: Switch case is in protected scope
  • Index(es):
    • Date
    • Thread