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

--- Comment #13 from Alex Coplan <acoplan at gcc dot gnu.org> ---
Clang recognizes the "cxx_defaulted_functions" feature to detect whether "=
default" functions are supported.

It's clear that __has_feature (cxx_defaulted_functions) should evaluate to 1
for -std=c++11 and above. It's less clear whether GCC intends to support "=
default" functions in C++98 mode as an extension, and therefore whether
__has_extension (cxx_defaulted_functions) should evaluate to 1 with -std=c++98.

I noticed that e.g. we accept:

struct S {
    int x;
    S(int a) : x(a) {}
    S() = default;
};
void f() {
    S s;
}

with -std=c++98 and emit a -Wc++11-extensions warning. This suggests that "=
default" might be supported as an extension, but it's not clear. By contrast,
it seems that deleted functions (detected with "cxx_deleted_functions") aren't
supported in C++98 mode, since e.g.

struct S {
    S() = delete;
};
void f() {
    S s;
}

doesn't get rejected with -std=c++98. It would be good to get some input from
C++ maintainers on the cxx_defaulted_functions case.

Reply via email to