Article View: comp.sys.mac.programmer.codewarrior
Article #860Long long, optimization and weird debugger errors
From: Jason Botwick
Date: Thu, 23 Jan 2003 05:13
Date: Thu, 23 Jan 2003 05:13
47 lines
3139 bytes
3139 bytes
OK, so I have this code:
void TBlockStreamDocument::ReserveDiskSpace(long long &requestedSpace)
{
HParamBlockRec pb;
long long freeBytes;
BlockZero_AC(pb);
if (fDocStream->GetFile()->GetVolumeInfo(pb) == noErr)
{
// pb.*.* are both unsigned longs that return the amount
// of free disk blocks and the size of these blocks, respectively.
long long ioVFrBlk = pb.volumeParam.ioVFrBlk;
long long ioVAlBlkSiz = pb.volumeParam.ioVAlBlkSiz;
freeBytes = ioVFrBlk * ioVAlBlkSiz;
}
else
freeBytes = 0;
if (freeBytes < requestedSpace)
requestedSpace = 0;
}
In my debug version of this app (optimization level 0), this works as
expected. In my release version (optimization level 4), this function sets
requestedSpace to 0 every time, because freeBytes always is set to 0. During
debugging, I can see that the "if" block is always executed in both the
release and debug versions. However, if I look at the variables window, in
the debug version, I can see where freeBytes is set to the appropriate value
in the debug version. But in the release version, the "value" of freeBytes
according to the debugger is "*Buffer for SetVariable must be exact size of
variable*"
WTF?
No idea what that is supposed to mean. But coming out of the "if" block,
freeBytes is always 0 in the release version, but it's set to the correct
value in the debug version under identical circumstances.
If I change all of the long longs in this example to plain old longs, it
works. Which would be an OK solution, except that these days, a 32 bit int
isn't big enough to store the number of free bytes someone might have
available on their hard disk.
Is this an optimization bug, or am I missing something simple here?
Technical Details
Message-ID:
<BA54E438.7596%jbotwick@nc.rr.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!nf3.bellglobal.com!cyclone.mw.ipsvc.net!news.mw.ipsvc.net!cyclone.kc.rr.com!news-west.rr.com!cyclone.tampabay.rr.com!news-post.tampabay.rr.com!twister.southeast.rr.com.POSTED!53ab2750!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10bcce,9970b840368bc3e,start X-Google-Attributes: gid10bcce,public X-Google-Thread: f635e,9970b840368bc3e,start X-Google-Attributes: gidf635e,public X-Google-Thread: fd047,9970b840368bc3e,start X-Google-Attributes: gidfd047,public X-Google-ArrivalTime: 2003-01-22 21:13:43 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!nf3.bellglobal.com!cyclone.mw.ipsvc.net!news.mw.ipsvc.net!cyclone.kc.rr.com!news-west.rr.com!cyclone.tampabay.rr.com!news-post.tampabay.rr.com!twister.southeast.rr.com.POSTED!53ab2750!not-for-mail User-Agent: Microsoft-Entourage/10.0.0.1309 Subject: Long long, optimization and weird debugger errors From: Jason Botwick <jbotwick@nc.rr.com> Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac,codewarrior.windows Message-ID: <BA54E438.7596%jbotwick@nc.rr.com> Mime-version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Lines: 48 Date: Thu, 23 Jan 2003 05:13:42 GMT NNTP-Posting-Host: 66.26.80.68 X-Complaints-To: abuse@rr.com X-Trace: twister.southeast.rr.com 1043298822 66.26.80.68 (Thu, 23 Jan 2003 00:13:42 EST) NNTP-Posting-Date: Thu, 23 Jan 2003 00:13:42 EST Organization: Road Runner - NC