From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 38AC03858D32; Sun, 8 Oct 2023 02:13:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38AC03858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696731183; bh=epGYb/JlQTpMCKQaKKx4ZraKs+BtQebax6C3M80/OMk=; h=From:To:Subject:Date:From; b=FTRHIsWi086JCRcw4Im+Qekdb1sP7qTNonKSIXjR6fk34dDh5LhVCpsE0dkF5h7EN gvxWHb3xzrV9lourjLkdtFLpGiWcYIctZTiJIrGED7vzcTuantKc1zX6/9S84O1bKf iu6zDJqqIaFHd0nSqSi0oMlAKsHRUk1hbdcWzFpQ= From: "de34 at live dot cn" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: de34 at live dot cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111723 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 f= or 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 #include #include namespace nonstd { template struct in_fun_result { [[no_unique_address]] I in; [[no_unique_address]] F fun; template requires std::convertible_to && std::convertible_to constexpr operator in_fun_result() const& { return {in, fun}; } template requires std::convertible_to && std::convertible_to constexpr operator in_fun_result() && { return {std::move(in), std::move(fun)}; } }; } int main() { std::ranges::in_fun_result r1{}; std::ranges::in_fun_result r2 =3D r1; // should be error,= but not diagnosed by default nonstd::in_fun_result r3{}; nonstd::in_fun_result r4 =3D 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= .=