This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1071. Literal class types and trivial default constructors

Section: 6.8  [basic.types]     Status: C++11     Submitter: Daniel Krügler     Date: 2010-06-02

[Voted into the WP at the March, 2011 meeting.]

According to 6.8 [basic.types] paragraph 10, one of the requirements for a literal class type is

This rule has unfortunate consequences. For example, in

    struct A { int x; };
    struct B: A { int y; };

B is a literal type, even though it is impossible to initialize a constant of that type. Conversely, in

    struct C {
        int a, b;
        constexpr C(int x, int y): a(x), b(y) { }
    };
    struct D {
        int x;
        C c;
    };

D is not a literal type, even though it could be initialized as an aggregate.

It would be an improvement to replace the requirement for a trivial default constructor with a requirement that the class be an aggregate.

Proposed resolution (November, 2010):

This issue is resolved by the resolution of issue 981.