CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Application developed under C++6.0 NT crash under W95and98 (initialization of variable)

    My team develop a software with visualC++6.0 under NT. Testing of the application under NT is good. But, with Windows95 and 98, our application crash in several points. We've found that variables not initialize in the code yield a error. This missing initialization seems to be relevant for Windows95 or 98 but do not yields any bugs under NT. Do you know if visual offers a option or a setting for this type of bug. Because we have to fixe it variable per variable in the sources of several developer teams.... Thank you


  2. #2
    Guest

    Re: Application developed under C++6.0 NT crash under W95and98 (initialization of variable)

    >We've found that variables not initialize in the code yield a error.

    Let me get this straight. You are using uninitialized variables and you are SUPRISED that the code does not work properly?!?!? I hope to god that non of them are pointers! You ALWAYS initialize variables before use!

    >Do you know if visual offers a option or a setting for this type of bug.

    BUG??? It amazes me when people fail to follow proper programming practices and then blame the results on a "bug".

    Fix your code to initialize all variables and especially all pointers (also a good idea to declare pointers like "CMyClass * foo = NULL;" and then test for NULL in ASSERTS where you use them.%3

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Application developed under C++6.0 NT crash under W95and98 (initialization of variable)

    You are supposed to initialize all variables. It has *nothing* to do with running Win 95/98, NT, UNIX, OS/2, Beos, Linux, whatever.

    Uninitialized variables are the major cause of software written in C or C++ working great on one machine, and failing on another.

    Regards,

    Paul McKenzie


  4. #4
    Join Date
    Apr 1999
    Posts
    48

    Re: Application developed under C++6.0 NT crash under W95and98 (initialization of variable)

    The only real fix is to pay out for a good tool like Purify or Boundschecker to check for erroneous use of variables/heap and then have a test plan that ensures full coverage of your program paths. Both tools have their strengths but personally I prefer Purify because you don't have to rebuild the app to use it. Good coding practice will get you so far, but something always sneaks through.
    NT clears memory in some situations where 95 doesn't, and zero is often the value you meant to assign anyway so you think you got it right until you try 95. In Release mode the compiler will sometimes warn about "used before initialized variables"; treat it as an error, not a warning.


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