[Bug c++/82110] New: Concept for default constructing works with new T, not with new T[1]

barry.revzin at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Sep 6 00:04:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82110

            Bug ID: 82110
           Summary: Concept for default constructing works with new T, not
                    with new T[1]
           Product: gcc
           Version: c++-concepts
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

This example fails with all versions of gcc currently:

struct X {
    X() = delete;
};

template <class T>
concept bool C = requires(T t) {
    new T;
};

template <class T>
concept bool D = requires(T t) {
    new T[1];
};

int main() {
    static_assert(!C<X>); // ok
    static_assert(!D<X>); // error
}

new T[1] still requires a public default constructor, just like new T, but X is
thought to model D (despite correctly not modeling C).


More information about the Gcc-bugs mailing list