From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-smtp-sop.national.inria.fr (mail3-smtp-sop.national.inria.fr [192.134.164.98]) by sourceware.org (Postfix) with ESMTPS id A7B113858C3A for ; Sun, 23 Jan 2022 11:25:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A7B113858C3A 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,310,1635199200"; d="scan'208";a="3831113" Received: from 85-171-189-19.rev.numericable.fr (HELO hippo) ([85.171.189.19]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 12:25:40 +0100 Date: Sun, 23 Jan 2022 12:25:38 +0100 (CET) From: Marc Glisse Reply-To: gcc-help@gcc.gnu.org To: Vishal Subramanyam cc: "gcc-help@gcc.gnu.org" Subject: Re: Pure/const function not getting executed as the first operand to logical OR ( || ) (C++) In-Reply-To: Message-ID: <4f40d38e-dc36-ada8-d116-4020b5c84cfc@hippo.saclay.inria.fr> References: <7107aa063c391c0c3dd9e1b9641f7e5a5df9aa31.camel@mengyan1223.wang> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP 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-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jan 2022 11:25:42 -0000 On Sun, 23 Jan 2022, Vishal Subramanyam via Gcc-help wrote: > is there a specific name for the type of optimization where the compiler simply decides to drop the return value. Gcc handles this as part of dead code elimination (among others). A simpler example would be int main(){ 1/0; } which does not crash either. If you want to make your function func opaque to the optimizers, you may be interested in __attribute__((noipa)). Using volatile would also avoid some optimizations. -- Marc Glisse