Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Why the results of debug and release version is different.

Reply
Thread Tools

Why the results of debug and release version is different.

 
 
bantamweight@gmail.com
Guest
Posts: n/a
 
      09-09-2006
Hi,
I create a project with vs2005 (both c++ and c# are used, sames the
problem is about c++) and it working well in Debug version but the
result is wrong in Release version. I checked again and again and no
difference of logic is found between two versions. I'm confused and
don't known how to correct it. Is there anyone encountered similar
deed? Any tips is wellcome.

Regards.

Bai Xiaoliang.

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      09-09-2006
bantamweight wrote;

> I create a project with vs2005 (both c++ and c# are used, sames the
> problem is about c++) and it working well in Debug version but the
> result is wrong in Release version. I checked again and again and no
> difference of logic is found between two versions. I'm confused and
> don't known how to correct it. Is there anyone encountered similar
> deed? Any tips is wellcome.


You have a bug. The bug has different symptoms in both builds.

Either post some code, or add unit tests to your code, or write it again
without the bug (not a joke), or post this question to
news:microsoft.public.vc.language .

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
 
 
 
Markus Grueneis
Guest
Posts: n/a
 
      09-09-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) schrieb:
> Hi,
> I create a project with vs2005 (both c++ and c# are used, sames the
> problem is about c++) and it working well in Debug version but the
> result is wrong in Release version. I checked again and again and no
> difference of logic is found between two versions. I'm confused and
> don't known how to correct it. Is there anyone encountered similar
> deed? Any tips is wellcome.
>


You maybe misused the assert() macro (aka ASSERT, _ASSERTE or whatever
your compiler provides you additionally).

Or maybe you have used some LOG macro, which is defined differently for
_DEBUG and NDEBUG preprocessor options?

This way the logic _looks_ the same, but it isn't. Some tip for
debugging: try to find out _when_ the error occurs. This is simple
with some traces, it's probably much work with single-step-debugging,
though. Then you should not have to search all the sources, but just
look at the last correct function.


best regards,
-- Markus

> Regards.
>
> Bai Xiaoliang.
>

 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      09-09-2006
(E-Mail Removed) wrote:

> Hi,
> I create a project with vs2005 (both c++ and c# are used, sames the
> problem is about c++) and it working well in Debug version but the
> result is wrong in Release version.



A common behavior with debug versions is to set automatic variables,
something that's not required by the standard and is usually not done
in release modes (for whatever "debug" and "release" modes mean in a
particular implementation).

You mave have an uninitialized variable somewhere. It's hard for us to
tell without code. Reduce it to the smallest possible program that
still demonstrates the problem and post it. In reducing it, you
pinpoint the error on your own.





Brian
 
Reply With Quote
 
bantamweight@gmail.com
Guest
Posts: n/a
 
      09-10-2006
Hi,
Thanks for all kindly answers.
The problem is caused by my negligence.
My solution including several projects, yesterday, I moved one header
file which including template classes from project A to B and corrected
implemention of the template classes. I only build the release verion
of the solution without clean solution first. Thus the wrong result is
gotten. And after clean the solution firstly before build the
solution(or rebuild), every thing is right.

Regard.

Bai Xiaoliang

 
Reply With Quote
 
Ron Natalie
Guest
Posts: n/a
 
      09-10-2006
Markus Grueneis wrote:
> (E-Mail Removed) schrieb:
>> Hi,
>> I create a project with vs2005 (both c++ and c# are used, sames the
>> problem is about c++) and it working well in Debug version but the
>> result is wrong in Release version. I checked again and again and no
>> difference of logic is found between two versions. I'm confused and
>> don't known how to correct it. Is there anyone encountered similar
>> deed? Any tips is wellcome.
>>

>
> You maybe misused the assert() macro (aka ASSERT, _ASSERTE or whatever
> your compiler provides you additionally).
>

Or most likely he is using free'd or unitialized memory. In debug
mode the Visual Studio runtimes fills free'd and uninited memory with
a distinctive hex pattern. It also puts guard areas around memory
allocations. In release it doesn't do any of this which so you
can get quite different behavior.
 
Reply With Quote
 
Markus Grueneis
Guest
Posts: n/a
 
      09-10-2006
Ron Natalie schrieb:
> Markus Grueneis wrote:
>> (E-Mail Removed) schrieb:
>>> [...]
>>>

>>
>> You maybe misused the assert() macro (aka ASSERT, _ASSERTE or whatever
>> your compiler provides you additionally).
>>

> Or most likely he is using free'd or unitialized memory. In debug
> mode the Visual Studio runtimes fills free'd and uninited memory with
> a distinctive hex pattern. It also puts guard areas around memory
> allocations. In release it doesn't do any of this which so you
> can get quite different behavior.


Yes, this has bitten me also several times when maintaining some old or
otherones code. Nothing less common than some buffer which is too
small, and just happened to not chrash because of.. pff... luck?

I've encountered similar problems when porting some code from vc6 to
vc8. The more aggressive optimization in the newer version sometimes
also brought some waiting buffer overflows to light, and then you just
sit there thinking "but that was said to be working for 3 years now!".


-- Markus
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Where to get stand alone Dot Net Framework version 1.1, version2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? MowGreen [MVP] ASP .Net 5 02-09-2008 01:55 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? PA Bear [MS MVP] ASP .Net 0 02-05-2008 03:28 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? V Green ASP .Net 0 02-05-2008 02:45 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Release version 30 times slower than debug version croeltgen Java 1 10-24-2004 11:49 PM



Advertisments