From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 2AFE23858D28 for ; Sun, 23 Jul 2023 14:14:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AFE23858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31751d7d96eso441224f8f.1 for ; Sun, 23 Jul 2023 07:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690121679; x=1690726479; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=j3PaHynuojJyikZy0ZGjJYGAuWpcSPKxBRCgn1L0A5w=; b=lbo23wMX0rQTMmfsakVoWNW7wWcmlDuuR9NxKCJapm8CF0a+ueYuSYbehDRJM0DLyK 8mGodE7Oo9FboCvqAv4GK6jivXyPbLHPjvOd9B5eVfcaKR99+w1lEuxAucG/hti0weyn H9eynL0IwAuh9HlUODzGN++ZnV9IJyfhPs/AsQKGVZkYrxb5ipsw1DX6lxV357nUqXhR V7FBpjIjiNU4DZzNBXlbtOz/vix5YKrCLAoY5HIHpVjpaiIuML+h7SAwiArPJ81S+UVV 4ZtYmvUsfChL+bgQpQ8uPWuCDnAp56n55xpq3iUN7uJJeKqCMD/hnggHwDkHS1rVlhb1 2iRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690121679; x=1690726479; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=j3PaHynuojJyikZy0ZGjJYGAuWpcSPKxBRCgn1L0A5w=; b=cqQFbJHV29WoM4e2jdbaZmTlFBJcxCWwP7LP/jC7q2INuGhHu4UqrNaytui3qouPHH XFiGLBz/Ux68m9FSmFcAtpOoCgt69PZlbyiPamDQD3Y9mP1Wuz1rgdej1CShwzIeAXdB 4Q8pn64i4GeWcDCWTaNiCtS4YbvqEtIg9oq4GSimmLkOKgMydZi0EGjnSaglBpbGC6cY uNEUSHBgG9smZXfpZZzqTzqbT9vgD8s8s8GCdI31dO/9Fc5rDqD26BYVmveqQH/NZ9Jm XwFGsKql41R2M+mWHk4U/zq60IJ4urZzQze5I+1dtTa4MMcokWb1FL9k6ivHW2YU3RIY qVTw== X-Gm-Message-State: ABy/qLbQ6jC+6NgT9rPLiW1LNhxdBCiCw/47xvFI+502qJYPtrOaWYw6 qQt3TFnY18ZAxPGTxUE5FmM= X-Google-Smtp-Source: APBJJlHdvCwvH0r2qETvovpbtUy7msPrGEzX6INVhQImgsQPQ8i1XB7BZq5CXyW4EW8c5ma+qpQyRg== X-Received: by 2002:adf:fe08:0:b0:313:ec5d:95b5 with SMTP id n8-20020adffe08000000b00313ec5d95b5mr5245646wrr.60.1690121678417; Sun, 23 Jul 2023 07:14:38 -0700 (PDT) Received: from [10.26.0.13] ([185.159.157.19]) by smtp.gmail.com with ESMTPSA id c16-20020adfe750000000b0030fb828511csm9832399wrn.100.2023.07.23.07.14.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Jul 2023 07:14:37 -0700 (PDT) Message-ID: Date: Sun, 23 Jul 2023 16:14:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: Avoid removing an if (false) statement and its corresponding branch Content-Language: en-US To: Julian Waters , gcc-help@gcc.gnu.org References: From: Gabriel Ravier In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 7/23/23 14:45, Julian Waters via Gcc-help wrote: > Hi all, > > Is there a way to stop gcc from nuking an if (false) statement and the > corresponding branch from the compiled code for debugging purposes? > Even turning off all optimizations doesn't achieve this > > best regards, > Julian IMO the simplest way would be to define something like `static const volatile bool unoptimizable_false = false;` somewhere and use it in place of `false`, when you want to avoid the if statement being optimized out.