From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 73A7C3858D33; Mon, 11 Jan 2021 13:42:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73A7C3858D33 From: "m.cencora at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98620] New: SFINAE code in class specialization generate warnings Date: Mon, 11 Jan 2021 13:42:45 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: m.cencora at gmail dot com 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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jan 2021 13:42:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98620 Bug ID: 98620 Summary: SFINAE code in class specialization generate warnings Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: m.cencora at gmail dot com Target Milestone: --- Following code compiled in any gcc>=3D5, C++11 or higher, and -Wmissing-field-initializers generate compiler warning: g++ -std=3Dc++20 -Wmissing-field-initializers #include template struct TmpArray { T arr[1]; }; template struct is_non_narrowing_conversion : std::false_type {}; template struct is_non_narrowing_conversion< Src, Dst, decltype(void(TmpArray{{ std::declval() }})) > : std::true_type {}; struct mystruct { int a; void * b; }; void test_nok() { is_non_narrowing_conversion::type v; } SFINAE is used here only to detect if a code compiles, and code inside the decltype should not generate warnings. Also this is inconsistent, because when SFINAE is used in function template= the warning is not generated: template auto is_non_narrowing_conversion_func_impl(Src&&, int) -> decltype((TmpArray{{ std::declval() }}, std::true_type{})); template auto is_non_narrowing_conversion_func_impl(Src&&, ...) -> std::false_type; template using is_non_narrowing_conversion_v2 =3D decltype(is_non_narrowing_conversion_func_impl(std::declval(), 0)= ); void test_ok() { is_non_narrowing_conversion_v2 v; }=