Why the results of debug and release version is different.

Discussion in 'C++' started by bantamweight@gmail.com, Sep 9, 2006.

  1. Guest

    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.
    , Sep 9, 2006
    #1
    1. Advertising

  2. Phlip Guest

    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!!!
    Phlip, Sep 9, 2006
    #2
    1. Advertising

  3. 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.
    >
    Markus Grueneis, Sep 9, 2006
    #3
  4. Default User Guest

    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
    Default User, Sep 9, 2006
    #4
  5. Guest

    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
    , Sep 10, 2006
    #5
  6. Ron Natalie Guest

    Markus Grueneis wrote:
    > 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.
    Ron Natalie, Sep 10, 2006
    #6
  7. Ron Natalie schrieb:
    > Markus Grueneis wrote:
    >> 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
    Markus Grueneis, Sep 10, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. croeltgen
    Replies:
    1
    Views:
    489
    Andrew Thompson
    Oct 25, 2004
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,744
    Smokey Grindel
    Dec 2, 2006
  3. Replies:
    3
    Views:
    300
    Ivan Vecerina
    Nov 7, 2006
  4. V Green
    Replies:
    0
    Views:
    824
    V Green
    Feb 5, 2008
  5. Hans Stoessel
    Replies:
    4
    Views:
    844
    Hans Stoessel
    Apr 22, 2010
Loading...

Share This Page