Thread: How overload a define macro?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by phantomotap View Post
    Still... I think I'm in love. First person I ever met that has the good sense to keep an assert in release builds.
    I'm not sure if this is sarcasm, but assuming it isn't, I'm one of the followers of that school of thought as well.

    Having the asserts get compiled in only for debug, encourages you to do final testing in debug configuration. This is, of course, a tragically wrong thing to do. When you test in debug, then recompile for release, and don't repeat all of your testing again, what you have essentially done is released a completely untested binary.

    You might attempt to argue that if the assert didn't get triggered in debug, it wouldn't be triggered in release, but that naively ignores the fact that bug behavior can change dramatically when moving to release mode.

    So, you either have to give up the concept of asserts altogether, or you have to leave them in the release build. I choose the second option...

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I'm not sure if this is sarcasm, but assuming it isn't, I'm one of the followers of that school of thought as well.
    Nope. Not sarcasm. (Well, not entirely. ^_^)

    Beyond what you, and the other guys, have pointed out, I've just rarely seen the things used in ways that they can safely be removed from release builds. (That is to say, I usually see 'std::assert' used in code that has side effects that must remain in release builds for the code to perform correctly.)

    Naturally, being me, I try to avoid them in favor of compile-time firewalls, but when I do use my form of assert, which either throws a complex exception that supports "appended" types and information or 'abort's outright, the only difference between debug and release builds is where the debug information is presented by default--debug console versus a file dump.

    Soma

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by brewbuck View Post
    This is, of course, a tragically wrong thing to do. When you test in debug, then recompile for release, and don't repeat all of your testing again, what you have essentially done is released a completely untested binary.
    I don't do debug builds unless I'm, well, debugging. All unit testing and QA is done on the release build

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by medievalelks View Post
    I don't do debug builds unless I'm, well, debugging. All unit testing and QA is done on the release build
    Of course. The point is, if the asserts are disabled for release, then your QA testing (in other words, the real testing) will never hit them, which makes them pointless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me with function call
    By NeMewSys in forum C++ Programming
    Replies: 16
    Last Post: 05-22-2008, 01:53 PM
  2. C Programming 2d Array Question
    By jeev2005 in forum C Programming
    Replies: 3
    Last Post: 04-26-2006, 03:18 PM
  3. whats wrong here
    By sreetvert83 in forum C++ Programming
    Replies: 15
    Last Post: 09-21-2005, 10:05 AM
  4. Error check problem again
    By rtransfi in forum C Programming
    Replies: 6
    Last Post: 02-27-2003, 04:55 PM