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

            Bug ID: 81349
           Summary: Classes with deleted constructor templates incorrectly
                    labeled as non-aggregates
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eraz at umich dot edu
  Target Milestone: ---

Simple test case (https://wandbox.org/permlink/HrAlAYZCEoJJMo1w):

    #include <type_traits>

    struct S {
        template <typename T>
        S(T) = delete;
    }

    int main() {
        static_assert(std::is_aggregate_v<T>);
    }

According to [dcl.init.aggr-1] (http://eel.is/c++draft/dcl.init.aggr#1), the
class `S` satisifes the requirements of an aggregate. The constructor template
is not user-provided since it is explicitly deleted on its first declaration
(http://eel.is/c++draft/dcl.fct.def.default#5.sentence-2). The rest of the
requirements are evidently satisfied.

Consequently, this bug manifests as an invalid selection of the constructor
template as an overload candidate when attempting aggregate initialization
(https://wandbox.org/permlink/jDwulQNsoAR5BIIT). This behavior can be observed
with every GCC version back to 4.7.3 compiled using the C++11 standard
(https://wandbox.org/permlink/5EvKUdxllToCDbYH). Though the requirements have
changed in C++17 from that in C++11 and C++14
(https://timsong-cpp.github.io/cppwp/n3337/dcl.init.aggr#1), the class still
satisfies the requirements but is treated as a non-aggregate type.

Reply via email to