Analyze reports issue when constant declared outside of method

Originator:smartgo
Number:rdar://11720796 Date Originated:6/21/2012
Status:Open Resolved:
Product:Developer Tools Product Version:XCode 4.5 (4G78z)
Classification:Other Bug Reproducible:Always
 
21-Jun-2012 01:54 PM Anders Kierulf:
Summary:
Analyze reports an issue when there's no issue. Only happens when a constant is declared outside of a method and based on another constant.

Steps to Reproduce:

Run Analyze on the following code:

// Declaring this here will causes Analyze to fail, claiming the value assigned to 'temp'
// is garbage or undefined. If MaxPoint is declared as 19 directly, Analyze is happy.
const int MaxSize = 19;
const int MaxPoint = MaxSize;

- (void)analyzeFailure
{
   // If the same declaration is moved within the method, Analyze is happy.
   // const int MaxSize = 19;
   // const int MaxPoint = MaxSize;

   int point[MaxPoint];

   for (int i = 0; i < MaxPoint; i++)
	{	point[i] = 1;
	}

   int temp = point[0];
   assert(temp);
}

Expected Results:
Analyze should not report any issues.

Actual Results:
Analyze claims the value assigned to temp is garbage or undefined.

Regression:

Notes:
Minimal sample project including this code is attached.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!