-
October 5th, 2020, 05:01 PM
#1
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
-
October 5th, 2020, 09:43 PM
#2
Re: Assert in debug mode
Does the contents of VERIFY(f) evaluate to true or false?
You're putting in
Code:
(data.*memberfunc)(retVal)
-
October 6th, 2020, 01:58 AM
#3
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)
-
October 12th, 2020, 04:12 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|