CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2015
    Posts
    500

    Assert in debug mode

    Hello,

    I have the following defined:
    Code:
    #define VERIFY(f)          ASSERT(f)
    
    
    And from somewhere :
    template <typename T>
    T FnData(const CommonD& data, bool (CommonD::*memberfunc)(T&) const)
    {
      	T retVal;
    	VERIFY( (data.*memberfunc)(retVal) );
    	return retVal;
    }
    And when i run, I can see the valid member function is getting called. But not sure why the ASSERT is getting hit and throws exception at redline.. Please kindly help

    thanks a lot
    pdk

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Assert in debug mode

    Does the contents of VERIFY(f) evaluate to true or false?

    You're putting in
    Code:
    (data.*memberfunc)(retVal)

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Assert in debug mode

    Shouldn't

    Code:
    VERIFY( (data.*memberfunc)(retVal) );
    be

    Code:
    VERIFY( (memberfunc)(data) );
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Join Date
    May 2015
    Posts
    500

    Re: Assert in debug mode

    Thankyou Arjay and kaud.

    VERIFY( (data.*memberfunc)(retVal) ); was already there, part of legacy code.

    I was missing some initialisation, so verify was returning false. I corrected it. and it is ok now.

    Yes, VERIFY( (data.*memberfunc)(retVal) ); looks bit odd !!! ... But it is legacy code ...

Tags for this Thread

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