From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sourceware.org (Postfix) with ESMTPS id 511393858D28 for ; Sun, 30 Jan 2022 09:47:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 511393858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=inria.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=inria.fr X-IronPort-AV: E=Sophos;i="5.88,328,1635199200"; d="scan'208";a="4473169" Received: from for59-1_migr-88-160-150-141.fbx.proxad.net (HELO [192.168.86.171]) ([88.160.150.141]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2022 10:47:42 +0100 Message-ID: Date: Sun, 30 Jan 2022 10:47:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 To: gcc@gcc.gnu.org Content-Language: en-US From: Theodore Papadopoulo Organization: INRIA Subject: Enquiry Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jan 2022 09:47:44 -0000 Before creating a bug report, I want to check with the GCC community (all the more that checking that the problem has not yet been reported is complicated at leat for me). The following (admitedly buggy) program generates a segmentation violation on fedora 35 (this is with g++ 11.2.1 20211203 (Red Hat 11.2.1-7) (GCC)) when compiled with -O3 (other versions replacing unisgned by std::string may trigger the exception instead of the segv) bool assert_sthg(const unsigned s) {     if (s==123)         throw 1; } int main() {     assert_sthg(0);     return 0; } When compiling, we indeed get a warning: test.C:4:1: warning: control reaches end of non-void function [-Wreturn-type] I can well understand that the program being buggy that the optimizer is allowed to do anything including the observed segmentation violation. Yet the result is quite surprising.... The question is, in that case, wouldn't it be better to turn the warning into an error at -O3 ?     Thank's for any input.         Theo.