internal compiler error: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘const_decl’

With the release of iOS 4.2 SDK and Xcode 3.2.5 my project started failing with this error. I tracked the problem down to use of implicitly testing an Objective-C string literal for null/nil.

In my case it was buried inside a macro, such as

#define SOMEMACRO(s) (s ? [[[UIApplication sharedApplication] delegate] someMethod:s] : nil)

The problem is the s before the ?. The following line of code causes the compiler to crash:

SOMEMACRO(@"hello")

I changed the macro in question to explicitly compare against nil and my project now compiles.

#define SOMEMACRO(s) (s != nil ? [[[UIApplication sharedApplication] delegate] someMethod:s] : nil)

Test Case

@"" ? 1 : 0 // crashes
@"" != nil ? 1 : 0 // doesn't crash

Apple Bug Reporter # 8840656

Advertisements

About austinfrance

Technical Developer @ RedSky IT / Explorer Software
This entry was posted in Development, iPhone. Bookmark the permalink.

One Response to internal compiler error: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘const_decl’

  1. Kalle says:

    Good catch, thanks for that. First time I saw that was in a stupid assert() where I simply did assert(1 && @”the foo isn’t bar”); to simply get a clear message about it whenever/if ever that broke.

    -Kalle.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s