ros/ros_comm

ROS_ASSERT is not working

Closed this issue · 1 comments

I'm running Ubuntu 14.02 x64 and ROS Jade. I'm running into a weird issue with ROS_ASSERT. It compiles fine but it is not functioning as expected. I have following code and I realised it's not even executing the function SerialNumberFromHex():

    std::string serial_number_str;
    if(!config_nh_.getParam("serial_number", serial_number_str))
    {
        ROS_ERROR("You must specify a serial number");
        valid_ = false;
    }
    else
    {
        ROS_ASSERT( SerialNumberFromHex(serial_number_str, &serial_number_) );
        ROS_INFO_STREAM("serial number="<<serial_number_str<<" ,hex-> "<<serial_number_);
    }

Then I tried directly:

ROS_ASSERT(false);

, and surprisingly it is not throwing any error.

And exactly the same code works fine on another machine running Ubuntu 14.04 x64 without any issue (and ROS_ASSERT(false) will throw error as expected). The same code was definitely working before on the PC but not any more now. Because compilation has no issue (I rerun cmake and recompile everything including removing the lib files manually), any possible cause to this? (e.g. compiler issue, etc?)

ROS_ASSERT has the same semantic as the macro assert(). When NDEBUG is defined (which is the case for all non-debug builds) the macro is being disabled.