[ create a new paste ] login | about

Link: http://codepad.org/pyN4NCxd    [ raw code | output | fork ]

C++, pasted on Feb 4:
#include <iostream>

struct excep
{
	excep(const char *p) : p(p)
	{
	}
	const char *p;
};

const char *test1(void)
{
	char str[80] = "test";

	return str;
}

void test2(void)
{
	char str[80] = "test";

	throw excep(str);
}

int main(void)
{
	try
	{
		std::cout << test1() << std::endl;

		test2();
	}
	catch(excep &e)
	{
		std::cout << e.p << std::endl;
	}

	return 0;
}


Output:
1
2
3
cc1plus: warnings being treated as errors
In function 'const char* test1()':
Line 13: warning: address of local variable 'str' returned


Create a new paste based on this one


Comments: