I have testing code which does something like
EXPECT_CALL(mock, getSomeString()).WillOnce(Return(&testString));
where getSomeString()
is returning by reference:
std:string& getSomeString();
and get
../../../../src/test/unit/gmock/gmock-actions.h: In member function ‘testing::internal::ReturnAction<R>::operator testing::Action<Func>() const [with F = const std::string&(), R = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’:
../../../../src/test/unit/MyTests.cc:148: instantiated from here
../../../../src/test/unit/gmock/gmock-actions.h:467: error: creating array with negative size (‘-0x00000000000000001’)
What is the cause?