What can be said about the value of fundamental type members of moved from object during move construction?

Viewed 145

Consider this code

Foo f1;
Foo f2{ std::move(f1) };

I would expect the member values of f1 to no longer necessarily hold the values given by the default constructor. However, testing with multiple compilers using this implementation of Foo suggests otherwise.

class Foo
{
public:
    Foo() = default;
    Foo(Foo &&) = default;

    std::string s{ "foo" };
    bool t{ true };
    bool f{ false };
};

After the move f1.t is always true and f1.f is always false. As described in this question I would expect the values to either be nondeterministic or that both boolean values would have the same value. However, they seem to get the same value they would get from the default constructor.

Live example with GCC

Is this just a implementation details of my compilers (by coincidence the same) or is this in the standard?

1 Answers
Related