From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9BA143858C2C; Wed, 28 Jun 2023 08:32:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BA143858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687941174; bh=7FqaphMI3w52R/WauBOJ7t2eUVI2n2aHTmt/le3Q2ZI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FieytCIYArzOdNgWKesGtJUdQVOH6erqlFrIOro/LN5lipsph4PSzjadxYO94j2bj tZV8UriR4V4sbzDDhb1IKX1qpUzZSpWypn7VHAnq95y3VHGvvPSJHUNMR8XVPBoYAE ZpyOTlH33APXd9oweOSgonhEZ+VNmdLbDiWqwGxU= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110437] SIGILL when return missing in a C++ function with a condition Date: Wed, 28 Jun 2023 08:32:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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: Message-ID: In-Reply-To: References: 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=3D110437 --- Comment #13 from Jonathan Wakely --- (In reply to Jan =C5=BDi=C5=BEka from comment #12) > Another example pointed out by one colleague of mine: >=20 > int f(int a) > { > if (a =3D=3D 1) > exit(0); exit is marked noreturn so the compiler knows this function never reaches t= he end without returning. But a user-defined function like "log_and_exit" might not be marked noreturn, so the same argument applies there. The code is correct, but the compiler can't prove it, so it can't give an error by defa= ult. > That is true :-) but from software implementation if you reuse such a > function or it is a library I'd personally disallow this as this is bad > coding. But this will be opinionated so better not to dive to such a rabb= it > hole. Right, the C++ standard isn't based on opinions. If you want to disallow it, you can use -Werror=3Dreturn-type. That can't be the default though.=