I am curious about what is happening in this code I wrote almost by mistake:
#include
class Test
{
public:
Test() {
std::cout <<
Since you have a member variable of type int
, whose indeterminate value is copied to itself, the code is technically Undefined Behavior.
However, in practice, with current computers nothing bad will happen. But on the third hand, nothing good happens either.
Regarding warnings, that's a Quality Of Implementation issue. The C++ standard has nothing to say about that.