From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id B22E63857011 for ; Wed, 14 Feb 2024 12:44:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B22E63857011 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=westcontrol.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B22E63857011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=116.202.254.214 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707914694; cv=none; b=MOpHsjNPxrD18vNN7QYbmOUbkhLo1plWGA7rt8jGEIu/YTY0a4TPehFLnRInMsHNn5RV1Q4USFENE3MAkQNjwEq8TTgnNZ6kf5EZ4ZbecknjvPE5C0tHOcdwJ3Y9KYyjs+W2kZ1usZeLfWj5VwzOsw/ycMpv0neBJiOw7X1B0ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707914694; c=relaxed/simple; bh=L2lWQGcYICVY28SooidKDxtFoQTnIKs923ehWLq/gj8=; h=To:From:Subject:Date:Message-ID:Mime-Version; b=s+FtQGN/qvSvuesJCbpg1WSmbAn26zjD64KRHt7OKtxjylTUFncr9Utd9Rw+GVsphdudAmWW62FuzErYAOdUVeStf59lkIwuTLnVROjV9I3eWjv+cjEDdjDrZl6GBT+8+EyLxWCEqO7PQ8qT4+/eNZFoX/BPUt8sIzAY/LkLpqw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1raEd9-000AOD-9D for gcc-help@gcc.gnu.org; Wed, 14 Feb 2024 13:44:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-help@gcc.gnu.org From: David Brown Subject: Re: Compiler message -Wunused confusion Date: Wed, 14 Feb 2024 13:44:45 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-GB In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 14/02/2024 12:11, A. Mc. via Gcc-help wrote: > Hello, > > I am receiving the gcc compiler warning -Wunused-value computed not used. I > can confirm this is true in my embedded application, the statement never > switches. But I am completely confused as to why. It's essentially the > following code: > > volatile bool foo; > > while (true) { > if (foo == true){ > //do something > foo = false;} > else{ > //do something else > foo = true;} > } > > Which never switches. What could be the cause of this? > > Many thanks in advance! > My guess is that you have simplified the code a bit too much here. Something else is wrong. (It is a good idea to pare down the code to the minimum that demonstrates the problem, as you have tried to do here. But I think you have removed to much!) David