Wann ist ein privater Konstruktor kein privater Konstruktor?

Nehmen wir an, ich habe einen Typ und möchte seinen Standardkonstruktor als privat kennzeichnen. Ich schreibe folgendes:

class C {
    C() = default;
};

int main() {
    C c;           // error: C::C() is private within this context (g++)
                   // error: calling a private constructor of class 'C' (clang++)
                   // error C2248: 'C::C' cannot access private member declared in class 'C' (MSVC)
    auto c2 = C(); // error: as above
}

Groß

Aber dann stellt sich heraus, dass der Konstruktor nicht so privat ist, wie ich dachte:

class C {
    C() = default;
};

int main() {
    C c{};         // OK on all compilers
    auto c2 = C{}; // OK on all compilers
}    

Dies erscheint mir als sehr überraschendes, unerwartetes und ausdrücklich unerwünschtes Verhalten. Warum ist das in Ordnung?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage