diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 90e374c26..f2fb38a71 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3934,5 +3934,5 @@ std::string ValueType::str() const if (constness & (2 << p)) ret += " const"; } - return ret.substr(1); + return ret.empty() ? ret : ret.substr(1); } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index fdd89b854..a16565d85 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -3008,6 +3008,9 @@ private: } void valuetype() { + // stringification + ASSERT_EQUALS("", ValueType().str()); + // numbers ASSERT_EQUALS("signed int", typeOf("1", "1")); ASSERT_EQUALS("unsigned int", typeOf("1U", "1U"));