🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #863

Re: Long long, optimization and weird debugger errors

#863
From: MW Ron
Date: Thu, 23 Jan 2003 17:56
71 lines
3962 bytes
In article <BA54E438.7596%jbotwick@nc.rr.com>,
 Jason Botwick <jbotwick@nc.rr.com> wrote:

Hi,

In optimized code the actual code could be moved elsewehre or replaced 
so the value in the register does not reflect the variable when you 
think it should.

So I don't think this is a debugger bug.  However if you feel there is 
an optimization bug please submit this as a bug report to 
cw_bug@metrowerks.com  so we can look at it deeper.  Include a project 
that demonstrates the behavior.

Thanks, for the cooperation,

Ron
>
>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?
>

-- 
     Free Programming Courses at CodeWarrior U
          <http://www.codewarrioru.com>

 Metrowerks, maker of CodeWarrior  -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com
Technical Details
Message-ID: <mwron-CCE7FC.12565823012003@enews.newsguy.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!telocity-west!DIRECTV!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!feed.newsfeeds.com!cyclone-sf.pbi.net!129.250.175.17!pln-w!spln!dex!extra.newsguy.com!newsp.newsguy.com!mwron
References: <BA54E438.7596%jbotwick@nc.rr.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,9970b840368bc3e
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,9970b840368bc3e
X-Google-Attributes: gidf635e,public
X-Google-Thread: fd047,9970b840368bc3e
X-Google-Attributes: gidfd047,public
X-Google-ArrivalTime: 2003-01-23 10:20:54 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!telocity-west!DIRECTV!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!feed.newsfeeds.com!cyclone-sf.pbi.net!129.250.175.17!pln-w!spln!dex!extra.newsguy.com!newsp.newsguy.com!mwron
From: MW Ron <mwron@metrowerks.com>
Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac,codewarrior.windows
Subject: Re: Long long, optimization and weird debugger errors
Date: Thu, 23 Jan 2003 12:56:58 -0500
Organization: Metrowerks
Lines: 71
Message-ID: <mwron-CCE7FC.12565823012003@enews.newsguy.com>
References: <BA54E438.7596%jbotwick@nc.rr.com>
NNTP-Posting-Host: p-592.newsdawg.com
User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X)
X-Face: )mY~XFHLw)UOW!W#[Ljvxq6Ja7(g'#F0-g*&puNxR8hEJkd@Oue/70^.)I78\
        (%a%&Id211u"l/t.llWo/M|?15XUlx9!IGkdWiEmcasiyg"k;Q9[~XuE+`t2"*n(>nmm
        @L/q,TjMd5+H{gASEPDR^$