public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "acoplan at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60512] would be useful if gcc implemented __has_feature similary to clang
Date: Tue, 11 Apr 2023 16:39:48 +0000	[thread overview]
Message-ID: <bug-60512-4-6dRe0XFnH5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60512-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2023-04-11 16:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12 19:24 [Bug c++/60512] New: " eteran at alum dot rit.edu
2014-03-12 19:35 ` [Bug c++/60512] " glisse at gcc dot gnu.org
2014-03-12 19:36 ` pinskia at gcc dot gnu.org
2014-03-12 19:52 ` eteran at alum dot rit.edu
2014-03-12 20:16 ` glisse at gcc dot gnu.org
2023-01-03 16:41 ` acoplan at gcc dot gnu.org
2023-01-04 11:40 ` redi at gcc dot gnu.org
2023-01-06 14:50 ` jrtc27 at jrtc27 dot com
2023-02-02 16:43 ` jason at gcc dot gnu.org
2023-04-11 16:39 ` acoplan at gcc dot gnu.org [this message]
2023-05-05 16:31 ` acoplan at gcc dot gnu.org
2023-05-05 18:03 ` iains at gcc dot gnu.org
2023-05-05 18:19 ` iains at gcc dot gnu.org
2023-05-05 20:26 ` iains at gcc dot gnu.org
2023-05-09 10:37 ` [Bug c++/60512] would be useful if gcc implemented __has_feature similarly " acoplan at gcc dot gnu.org
2023-05-09 10:57 ` iains at gcc dot gnu.org
2023-05-09 11:13 ` iains at gcc dot gnu.org
2023-05-09 12:14 ` acoplan at gcc dot gnu.org
2023-11-27 10:46 ` cvs-commit at gcc dot gnu.org
2023-11-27 11:08 ` acoplan at gcc dot gnu.org
2023-12-11 21:53 ` egallager at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60512-4-6dRe0XFnH5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).