From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7709E385840B; Thu, 16 Dec 2021 08:56:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7709E385840B From: "antoshkka at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103745] New: Warn on throwing an exception not derived from std::exception Date: Thu, 16 Dec 2021 08:56:05 +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: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: antoshkka 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 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 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: Thu, 16 Dec 2021 08:56:05 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103745 Bug ID: 103745 Summary: Warn on throwing an exception not derived from std::exception Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- Throwing an exception that is derived from std::exception is a common pract= ice. Cases when that practice should be skipped are very rare. However, many beginners do not know about that and erroneously do not derive their except= ions from std::exception. There are also cases when classes have close names and users throw the wrong type by a typo. Please add a warning about throwing an exception not derived from std::exception. Godbolt playground: https://godbolt.org/z/7Phf3nafW=