CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    6

    strange but only in release mode

    this is my code:
    #include <stdlib.h>
    #include <stdio.h>

    typedef struct
    {
    double d1,d2;
    int iSize;
    } P;


    int filter(P *pP)
    {
    int j;
    pP->d1=107;
    pP->d2=61;
    pP->iSize=3;
    double dCond;

    dCond=(pP->d1<pP->d2);
    printf("dCond=%f\n",dCond);
    if (pP->d1 < pP->d2)
    {
    pP->iSize--;
    printf("inside if\n",j);
    }
    else
    pP->iSize--;
    return 0;
    }


    main()
    {
    P p;
    filter(&p);

    return 0;
    }

    in debug mode it is fine and the output is:
    dCond=0.000000

    but in release mode (when the optimization option under the C/C++ tab is 'maximize speed'). the output is strange (the if block is executed):
    dCond=0.000000
    inside if

    could someone have an explaination to this ?
    I'm running microsoft visual C++ 6.0 enterprise edition.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449
    The code worked fine for me, both in debug and release.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Apr 2002
    Location
    Tokyo
    Posts
    14
    Even the code worked fine at my end too both in debug and release mode!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured