I have a simple code which is basically like the one below:
static std::string const part1[] = {"Test1", "Test2", "Test3"};
static std::string const part2[] = {"Pass", "Fail", "Retry"};
std::string test = part1[1] + part2[0];
I have included the string
which in turn has the basic_string.h
. I know that there is an overloaded +
operator there.
When I built this I got no errors but when I tried to run it, I got a segmentation error.
The problem I noticed later is that if I simply try to print the array elements, I am seeing the same segmentation error.
I don't see where the memory leak is happening. Any clues?