public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Jason Merrill <jason@redhat.com>,
	Chung-Lin Tang <cltang@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Sandra Loosemore <sandra@codesourcery.com>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH] optc-save-gen.awk: adjust generated array compare
Date: Thu, 8 Sep 2022 20:01:38 +0200	[thread overview]
Message-ID: <d0f01b94-f12b-069a-11be-74581e554867@suse.cz> (raw)
In-Reply-To: <f3398a7e-5900-f259-68ca-701a764d3e9f@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

On 9/8/22 18:23, Jason Merrill wrote:
> It seems to me that the warning is pointing out that comparing the address of the array is nonsensical, and we should remove it and just have the memcmp.

Yes, thanks for the pointer. We should always compare the array types with memcmp.

Ready to be installed?
Thanks,
Martin

[-- Attachment #2: 0001-opts-always-compare-array-option-values-with-memcmp.patch --]
[-- Type: text/x-patch, Size: 1002 bytes --]

From 32e875bf395ebb0444ced281c5e7634474100fb8 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 8 Sep 2022 20:00:33 +0200
Subject: [PATCH] opts: always compare array option values with memcmp

gcc/ChangeLog:

	* optc-save-gen.awk: Always compare array option values with memcmp.
---
 gcc/optc-save-gen.awk | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 233d1fbb637..49065ced0b3 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1093,8 +1093,7 @@ for (i = 0; i < n_target_array; i++) {
 	name = var_target_array[i]
 	size = var_target_array_size[i]
 	type = var_target_array_type[i]
-	print "  if (ptr1->" name" != ptr2->" name "";
-	print "      || memcmp (ptr1->" name ", ptr2->" name ", " size " * sizeof(" type ")))"
+	print "  if (memcmp (ptr1->" name ", ptr2->" name ", " size " * sizeof(" type ")))"
 	print "    return false;";
 }
 for (i = 0; i < n_target_val; i++) {
-- 
2.37.3


  reply	other threads:[~2022-09-08 18:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 15:29 Chung-Lin Tang
2022-09-08 16:23 ` Jason Merrill
2022-09-08 18:01   ` Martin Liška [this message]
2022-09-08 19:35     ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0f01b94-f12b-069a-11be-74581e554867@suse.cz \
    --to=mliska@suse.cz \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=sandra@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).