Skip to content

Commit c12016b

Browse files
Merge pull request #5400 from hannes-steffenhagen-diffblue/fix/dangling-reference-in-unit-tests
Fix bug where reference to temporary string was returned
2 parents 037e860 + 04e12dc commit c12016b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

jbmc/unit/java-testing-utils/require_goto_statements.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,17 @@ class no_decl_found_exceptiont : public std::exception
3434
{
3535
public:
3636
explicit no_decl_found_exceptiont(const std::string &var_name)
37-
: _varname(var_name)
37+
: message{"Failed to find declaration for: " + var_name}
3838
{
3939
}
4040

4141
virtual const char *what() const throw()
4242
{
43-
std::ostringstream stringStream;
44-
stringStream << "Failed to find declaration for: " << _varname;
45-
return stringStream.str().c_str();
43+
return message.c_str();
4644
}
4745

4846
private:
49-
std::string _varname;
47+
std::string message;
5048
};
5149

5250
pointer_assignment_locationt find_struct_component_assignments(

0 commit comments

Comments
 (0)