• 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
crosses initialization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

crosses initialization


  • Subject: crosses initialization
  • From: Jonathan Taylor <email@hidden>
  • Date: Sun, 21 May 2006 13:54:58 +0100

I see from the archives this sort of question has been asked before, but none of the answers seem to address my current problem.

I have a whole load of code which involves code similar to the following test case:

long bar(void) { return 2; }

void foo(void)
{
goto ExitLabel;
long temp = 1;
long temp2 = bar();
long temp3 = 3;
long temp4;
temp4 = 4;
ExitLabel:
    return;
}

This always used to compile fine, but after I had to reinstall the OS (and thus the development tools as well), this code has stopped compiling. I get errors saying:

/Volumes/Development/temp/main.cpp: In function 'void foo()':
/Volumes/Development/temp/main.cpp:11: error: jump to label 'ExitLabel'
/Volumes/Development/temp/main.cpp:5: error:   from here
/Volumes/Development/temp/main.cpp:8: error:   crosses initialization of 'long int temp3'
/Volumes/Development/temp/main.cpp:6: error:   crosses initialization of 'long int temp'
/Volumes/Development/temp/main.cpp:6: warning: unused variable 'temp'
/Volumes/Development/temp/main.cpp:7: warning: unused variable 'temp2'
/Volumes/Development/temp/main.cpp:8: warning: unused variable 'temp3'

Notice that the compiler is NOT objecting to the initialization of temp2 or temp4, CW compiles the code fine, and GCC 4 certainly always used to compile it ok until today(!). My understanding is that (at least under C99) this is perfectly valid code as long as the variables being initialized are basic types rather than classes requiring constructors.

The command line is:
CompileC build/temp.build/Debug/temp.build/Objects-normal/ppc/main.o /Volumes/Development/temp/main.cpp normal ppc c++ com.apple.compilers.gcc.4_0
    cd /Volumes/Development/temp
    /usr/bin/gcc-4.0 -x c++ -arch ppc -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -g -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -mtune=G5 -fvisibility=hidden -fvisibility-inlines-hidden -mfix-and-continue -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Volumes/Development/temp/build/temp.build/Debug/temp.build/temp.hmap -F/Volumes/Development/temp/build/Debug -I/Volumes/Development/temp/build/Debug/include -I/Volumes/Development/temp/build/temp.build/Debug/temp.build/DerivedSources -isysroot /Developer/SDKs/MacOSX10.4u.sdk -c /Volumes/Development/temp/main.cpp -o /Volumes/Development/temp/build/temp.build/Debug/temp.build/Objects-normal/ppc/main.o

... and indeed "cc main.cpp" reports the same errors.

Can anyone suggest what I can do to get this to work? I would very much prefer not to have to rewrite all my existing code!

Thanks for any suggestions
Jonny
 _______________________________________________
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: crosses initialization
      • From: Kay Roepke <email@hidden>
    • Re: crosses initialization
      • From: Lawrence Gold <email@hidden>
    • Re: crosses initialization
      • From: Eric Albert <email@hidden>
  • Prev by Date: /Developer/Private/jam failed with exit code 1
  • Next by Date: Re: /Developer/Private/jam failed with exit code 1
  • Previous by thread: Re: /Developer/Private/jam failed with exit code 1
  • Next by thread: Re: crosses initialization
  • Index(es):
    • Date
    • Thread