4.2 compiler problems
4.2 compiler problems
- Subject: 4.2 compiler problems
- From: Steve Mills <email@hidden>
- Date: Thu, 24 Feb 2011 11:24:28 -0600
Anybody know of bugs in GCC 4.2 that weren't in 4.0 when generating C++ on 32-bit Intel? The version of our app that we're building for the Mac App Store is showing signs of compiler errors. We've used GCC 4.0 on our other builds, but for this version we had to switch to 4.2. Optimization is set to -Os on both builds. Here's the tiny, simple hunk of code that shows the problem.
These 2 are member variables of "this" class - the code is located in a method of the same class:
SInt32 m_origSelStart, m_replacedTextLength;
Going into this code, m_origSelStart is -1 and m_replacedTextLength is 0. The sel start and end of the variable flow are both 0, and GetSelect simply copies the flow's local member variables to those two parameters that are passed by pointer.
if(m_OrigSelStart == -1) {
SInt32 selEnd;
flow->GetSelection(&m_origSelStart, &selEnd);
printf("%ld %ld %ld\n", m_origSelStart, selEnd, selEnd - m_OrigSelStart);
m_replacedTextLength = selEnd - m_origSelStart;
}
The printf produces these results:
-1 0 1
It should be:
0 0 0
If I use another temporary variable to hold the selStart, then everything works as it should:
if(m_OrigSelStart == -1) {
SInt32 selStart, selEnd;
flow->GetSelection(&selStart, &selEnd);
m_origSelStart = selStart;
printf("%ld %ld %ld %ld\n", m_origSelStart, selStart, selEnd, selEnd - m_OrigSelStart);
m_replacedTextLength = selEnd - m_origSelStart;
}
printf produces:
0 0 0 0
I just recompiled with optimizations set to -O3, but that caused a crash in a completely different really simple function. Same with -O2. Setting it to -O1 fixes both compilation errors.
Steve Mills
Drummer, Mac geek
_______________________________________________
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