From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4F8A13858D1E; Wed, 14 Sep 2022 08:56:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F8A13858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663145775; bh=3nv28a2ZOkRogHFSMeu1BNk+7J0bErr2QgzHwi81brU=; h=From:To:Subject:Date:From; b=P93+UZ12CBHZNwmgp0K7QgAIi+CAIj6XcG4ov+HyR2PC+gKmvJ5dYNYIvYxS/UP5I IiPDNgJ+o1qvr/SvrbvGmDsaKfctDZZEA004zSwo4nyuQp3MBDZiWu9YYq5qwrK4Mc h2TaTF0SHCOKZPwGumfDvboIbZwf3N6JlX0jLQco= From: "felix.von.s at posteo dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106940] New: Feature request: -Wsuggest-noexcept and -Wsuggest-explicit Date: Wed, 14 Sep 2022 08:56:14 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: felix.von.s at posteo dot de 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106940 Bug ID: 106940 Summary: Feature request: -Wsuggest-noexcept and -Wsuggest-explicit Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: felix.von.s at posteo dot de Target Milestone: --- When writing classes, I routinely tend to forget that constructors can be u= sed for implicit conversions, unless marked explicit. I also tend to forget about noexcept specifiers, which can lead to performa= nce pitfalls, especially with move constructors and move assignment operators. So I would like a compiler warning that could remind me to consider such concerns. In case of noexcept, I don=E2=80=99t particularly need full sema= ntic analysis of the body; a pure syntax check whether the specifier is present should suffice. And in case of explicit, no other kind of check is possibl= e, obviously. I imagine -Wsuggest-explicit could be suppressed for copy and move construc= tors from the same type. I am undecided whether it should apply to conversion operators, but leaning towards yes. The warnings would be silenced by adding explicit specifiers: explicit(fals= e) and noexcept(false). Each warning should probably require the earliest language version where the respective silencing is possible (C++20 and C++1= 1, respectively).=