public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111723] New: #pragma GCC system_header suppresses errors from narrowing conversions Date: Sun, 08 Oct 2023 02:13:00 +0000 [thread overview] Message-ID: <bug-111723-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111723 Bug ID: 111723 Summary: #pragma GCC system_header suppresses errors from narrowing conversions Product: gcc Version: 13.2.1 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- In the following program, the conversions are narrowing, but only the one for nonstd::in_fun_result is rejected. When -Wsystem-headers is used, then the narrowing conversion for std::ranges::in_fun_result are correctly diagnosed. But if -pedantic-errors and -Wsystem-headers are used together, some standard headers are rejected. Godbolt link: https://godbolt.org/z/fT7b16eoe ``` #include <algorithm> #include <concepts> #include <utility> namespace nonstd { template<class I, class F> struct in_fun_result { [[no_unique_address]] I in; [[no_unique_address]] F fun; template<class I2, class F2> requires std::convertible_to<const I&, I2> && std::convertible_to<const F&, F2> constexpr operator in_fun_result<I2, F2>() const& { return {in, fun}; } template<class I2, class F2> requires std::convertible_to<I, I2> && std::convertible_to<F, F2> constexpr operator in_fun_result<I2, F2>() && { return {std::move(in), std::move(fun)}; } }; } int main() { std::ranges::in_fun_result<int, int> r1{}; std::ranges::in_fun_result<short, short> r2 = r1; // should be error, but not diagnosed by default nonstd::in_fun_result<int, int> r3{}; nonstd::in_fun_result<short, short> r4 = r3; // error, rejected with -pedantic-errors } ``` It seems to me that #pragma GCC system_header shouldn't suppress errors from narrowing conversions, because the diagnostics are required by the standard.
next reply other threads:[~2023-10-08 2:13 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-10-08 2:13 de34 at live dot cn [this message] 2023-10-08 2:21 ` [Bug c++/111723] " pinskia 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-111723-4@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: linkBe 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).