:

Bug in GetValueAndParam() function?

Added by: ~S.H.Bouwhuis, 2015 V 26

Added by: ~S.H.Bouwhuis, 2015 V 26

In TtMathObjects.h the following function is implemented:

/*!
this method gets the value and the number of parameters
of a specific object
*/
ErrorCode GetValueAndParam(const std::string & name, std::string & value, int * param) const
{
if( !IsNameCorrect(name) )
return err_incorrect_name;

CIterator i = table.find(name);

if( i == table.end() )
{
value.empty();
*param = 0;
return err_unknown_object;
}

value = i->second.value;
*param = i->second.param;

return err_ok;
}

Is it safe to say the line with the function value.empty(); is incorrect?
Testing whether value is empty makes no sense. Did you mean to clear the value? In that case, you should change it to value.clear();

If I'm right, could you please update your source code for the next release?

Added by: ~Marco, 2016 XI 17

I got pointed to it by cppcheck conde-analysis.

The "const char**" overload also cleans out the value pointer. I conclude this must be a mistake.

Added by: ~t, 2016 XI 17

yes, value.empty() is strange here, I have to check this.