• 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: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )


  • Subject: Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
  • From: "Sean McBride" <email@hidden>
  • Date: Fri, 9 Jul 2010 17:48:47 -0400
  • Organization: Rogue Research Inc.

On Fri, 9 Jul 2010 17:35:09 -0400, Eric Gorr said:

>#include <stdio.h>
>
>enum
>{
>	kMinimumWidth = 35
>};
>
>int main (int argc, const char * argv[])
>{
>    // insert code here...
>
>	int b;
>
>	b = kMinimumWidth;
>
>	const int kMinimumWidth = kMinimumWidth;
>
>	int a;
>
>	a = kMinimumWidth;
>
>    return 0;
>}
>
>What should the value of 'a' be?
>
>It seems like it should have a value of 35, but solely based on how I
>compile this code, it could end up with any random value regardless of
>what compiler I use.
>
>The problem, is clearly with the line of code:
>
>const int kMinimumWidth = kMinimumWidth;

I tried your snippit with the Comeau online compiler:
<http://www.comeaucomputing.com/tryitout/>

it said:

"ComeauTest.c", line 16: warning: variable "kMinimumWidth" is used
before its value
          is set
  	const int kMinimumWidth = kMinimumWidth;
  	                          ^


This seems to be the same problem as the snippit below, which gcc&clang
compile without error!

int main (int argc, const char * argv[])
{
	int x = x;

 return 0;
}

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


 _______________________________________________
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: 
 >Controlling optimization level per function (From: Eric Gorr <email@hidden>)
 >Re: Controlling optimization level per function (From: "Sean McBride" <email@hidden>)
 >Re: Controlling optimization level per function (From: Eric Gorr <email@hidden>)
 >Re: Controlling optimization level per function (From: "Sean McBride" <email@hidden>)
 >Re: Controlling optimization level per function (From: Eric Gorr <email@hidden>)
 >Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function ) (From: Eric Gorr <email@hidden>)

  • Prev by Date: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
  • Next by Date: Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
  • Previous by thread: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
  • Next by thread: Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
  • Index(es):
    • Date
    • Thread