#include <string>
#include <iostream>


struct Exception
{
        std::string what;
        Exception(const std::string & what_) : what(what_) {}
};


std::string f()
{
        throw Exception("Hello, world!");
}

void g()
{
        try
        {
                f();
        }
        catch (...)
        {
                throw Exception(f());
        }
}


int main(int argc, char ** argv)
{
        try
        {
                g();
        }
        catch (const Exception & e)
        {
                std::cerr << e.what << std::endl;
        }

        /// returns 1 in gcc 4.6.3, 4.8.1 - bug
        std::cerr << std::uncaught_exception() << std::endl;

        return 0;
}