From patchwork Fri Jul 19 16:52:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1962606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gotplt.org header.i=@gotplt.org header.a=rsa-sha256 header.s=dreamhost header.b=uckRb2gw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WQdmG6Wkxz1xpQ for ; Sat, 20 Jul 2024 04:41:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17D28384A4AC for ; Fri, 19 Jul 2024 18:40:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from olivedrab.birch.relay.mailchannels.net (olivedrab.birch.relay.mailchannels.net [23.83.209.135]) by sourceware.org (Postfix) with ESMTPS id 60901385ED72 for ; Fri, 19 Jul 2024 18:40:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60901385ED72 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 60901385ED72 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=23.83.209.135 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1721414439; cv=pass; b=VBjHbZ0sJdj7H/S80vfxOBYuhoKL1MsSvwwLIbRCCD5gxL/6iQnSk1Ku+3QGAfdfciQyEizuNWyr7VZ0uNcQPFXVPkj+kofvwm3S4uVZ6D07Ci4dKRrRi33BW6emGKdIDL6z49UeDy0bQVs01x+6mW8MD3J/DDh/mYvymjhf9nc= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1721414439; c=relaxed/simple; bh=y4WkqHn1BOTqn+co2ibKltHcubOJuixpRyOstBuit4A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NJDs4J5EjTsRYK7Kf90Hh3Ot0ZYq8vejtML0fPQjXopXTBzM8jq9K1xiqU2FpEqtQePtMARbqgTiRQ6bailNZtX/z9fTaM/LFw+X9yPQs0EDSMDC6NZmcuuUIv3wdldPtoatQa09WGiOzqmnKX3uBB/dP559dORqooeupbejnfQ= ARC-Authentication-Results: i=2; server2.sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 405B083209 for ; Fri, 19 Jul 2024 18:40:33 +0000 (UTC) Received: from pdx1-sub0-mail-a310.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D7C18865E1 for ; Fri, 19 Jul 2024 18:40:32 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1721414432; a=rsa-sha256; cv=none; b=WgXwViTX/q5axZ4rCMX0Oh5QerJfdDDoLx1cveF7ETqiVS33P3f7ur65o7bfn4SbUZRggm gflScRsGA3Qx+rc7fKOS0umM9gJrn8s3XGMr8ejm5kIS11eLl5qJ6Or5ab2gKMs+g0LbmI dtgohpu9vw9RB9owiljUfgqL8h/a25HClS1fJXpONBqU8FRjk09IjKWrHGJACWN9gGww9I 6qfY4Zj18ODvL1d6UpO2kdWXhSJo2bnVifQpCWgVue62wRbNJb/TROdBoY663nbfYAOBre nHTV3mMrU+WYZgGmHGfWGP1fX8kphI2pi0id/MiLSyn1f/0yHPplHh/+3b0pUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1721414432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=dpsa3xQeSKFvi7YvaPCs2PGOSR/3XvCk0AJk0nmuya0=; b=jxn56X7Zq/B0LTsGAkIhI06TLFsmFsaMtmW13AdD/Nr6O7hunFCk8krEQ4dg82RY4eL58l AzfavyCW/3268Rp27iZ3LmSMeAAsE52aaYht1NWA5UWy1p0SUnWNsW83HAjzI+1WMJ7oyr tvE1nwfyOy156JErZzUo4+9ORQ5OGt2rOHCTC5EqjMIt5FmRBoZe7H/FXxqaYeKQEcFL6u HEOV7oDThVXP1wDfM5OMeRbmLKm4ACE+EjimZ3NeGQOXNNasuF/veHG6k3oGUUx9O07J6o HtMPAKWzVSL6GgmVDS0eU4zTa+QgBwP/ZCdN1EU5lRQgZynBs9bh9XzyUmdVew== ARC-Authentication-Results: i=1; rspamd-5d9c874f6d-lvcgq; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Quick-Arch: 4b4cefe04c3ffbdd_1721414433095_1642251211 X-MC-Loop-Signature: 1721414433095:470099885 X-MC-Ingress-Time: 1721414433095 Received: from pdx1-sub0-mail-a310.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.126.239.233 (trex/7.0.2); Fri, 19 Jul 2024 18:40:33 +0000 Received: from fedora.. (bras-base-toroon4859w-grc-84-184-146-171-51.dsl.bell.ca [184.146.171.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a310.dreamhost.com (Postfix) with ESMTPSA id 4WQdlh3z9Fz1f for ; Fri, 19 Jul 2024 11:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1721414432; bh=dpsa3xQeSKFvi7YvaPCs2PGOSR/3XvCk0AJk0nmuya0=; h=From:To:Subject:Date:Content-Transfer-Encoding; b=uckRb2gwNI1HVtOnJ+0GxCa6bzNBbWqQAfSBq+jzM5RzKEOohVlFWbt46G5HcAkAT qIYMff0s+xOQJjLZL6VH+8623v4X92F+QOGeOPRijobVdSl3JK+XIEZCinDf4cP6f7 bq8UELDMBEANXZ4PYsOQctxhQjZ/bwDb2fj10DSFPL4K4FJedfdEbyOGjlxeezGcEu 2wRyGbfz374ql0EONUwiDZjK6x+d8I3Ss7uyZi/15TpoeMYIpImK3Q0IVKXYl63VFo BF7iJYHPKVIBHxDBta3iD0YYCGUo/Umf5aGzaJO5cXheYjZ6C0phDd43mrA3C/5lBd JwhB0LertH5WQ== From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid undefined behaviour in build_option_suggestions Date: Fri, 19 Jul 2024 12:52:06 -0400 Message-ID: <20240719165206.286881-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3035.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org The inner loop in build_option_suggestions uses OPTION to take the address of OPTB and use it across iterations, which is undefined behaviour since OPTB is defined within the loop. Pull it outside the loop to make this defined. It's a trivial fix, so posting early. OK to commit once build and test succeeds? Thanks, Sid gcc/ChangeLog: * opt-suggestions.cc (option_proposer::build_option_suggestions): Pull OPTB definition out of the innermost loop. --- gcc/opt-suggestions.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/opt-suggestions.cc b/gcc/opt-suggestions.cc index 849e4f5c439..71e5cb561a6 100644 --- a/gcc/opt-suggestions.cc +++ b/gcc/opt-suggestions.cc @@ -167,9 +167,9 @@ option_proposer::build_option_suggestions (const char *prefix) add_misspelling_candidates (m_option_suggestions, option, opt_text); + struct cl_option optb; for (int j = 0; sanitizer_opts[j].name != NULL; ++j) { - struct cl_option optb; /* -fsanitize=all is not valid, only -fno-sanitize=all. So don't register the positive misspelling candidates for it. */