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

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


  • Subject: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
  • From: Eric Gorr <email@hidden>
  • Date: Fri, 9 Jul 2010 17:35:09 -0400

I filed rdar://8176729

I think my problem, which was actually unrelated to the optimization level, discovered a bug in the compilers ( GCC4.2, GCC4.2-LLVM, & LLVM )

Here is a simple piece of code which demonstrates the problem:

#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 am not sure if the way this code is written has undefined behavior or if this is an actual bug in the compilers.

If it is undefined behavior, then it still seems like a bug in the compiler in that a warning or error should be emitted for this odd line of code.

In any case, writing this line of code was clearly an error in the real application and simply getting rid of it fixed the problem I was having.

Still....would like to have a better understanding of what the actual problem is.... (undefined behavior or just a bug in the compilers)

Any thoughts?


 _______________________________________________
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

  • Follow-Ups:
    • Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
      • From: Mark Wagner <email@hidden>
    • Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
      • From: Howard Moon <email@hidden>
    • Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
      • From: "Sean McBride" <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>)

  • Prev by Date: bug in Xcode and/or iphone simulator?
  • Next by Date: Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
  • Previous by thread: 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