public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Chung-Lin Tang <cltang@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "Sandra Loosemore" <sandra@codesourcery.com>,
	"Joseph Myers" <joseph@codesourcery.com>,
	"Martin Liška" <mliska@suse.cz>
Subject: Re: [PATCH] optc-save-gen.awk: adjust generated array compare
Date: Thu, 8 Sep 2022 12:23:30 -0400	[thread overview]
Message-ID: <f3398a7e-5900-f259-68ca-701a764d3e9f@redhat.com> (raw)
In-Reply-To: <56951572-c9b4-af2d-0e8b-9d47b87ba313@codesourcery.com>

On 9/8/22 11:29, Chung-Lin Tang wrote:
> Hi Joseph,
> Jan-Benedict reported a build-bot error for the nios2 port under --enable-werror-always:
> 
> options-save.cc: In function 'bool cl_target_option_eq(const cl_target_option*, const cl_target_option*)':
> options-save.cc:9291:38: error: comparison between two arrays [-Werror=array-compare]
>   9291 |   if (ptr1->saved_custom_code_status != ptr2->saved_custom_code_status
>        |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> options-save.cc:9291:38: note: use unary '+' which decays operands to pointers or '&'component_ref' not supported by dump_decl<declaration error>[0] != &'component_ref' not supported by dump_decl<declaration error>[0]' to compare the addresses
> options-save.cc:9294:37: error: comparison between two arrays [-Werror=array-compare]
>   9294 |   if (ptr1->saved_custom_code_index != ptr2->saved_custom_code_index
>        |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ...
> 
> This is due to an array-typed TargetSave state in config/nios2/nios2.opt:
> ...
> TargetSave
> enum nios2_ccs_code saved_custom_code_status[256]
> 
> TargetSave
> int saved_custom_code_index[256]
> ...
> 
> 
> This patch adjusts the generated array state compare from 'ptr1->array' into '&ptr1->array[0]' in gcc/optc-save-gen.awk,
> seems sufficient to pass the tougher checks.
> 
> Tested by ensuring the compiler builds, which should be sufficient here.
> Okay to commit to mainline?

Martin added the array support in r219636, any thoughts?

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.

> Thanks,
> Chung-Lin
> 
> 	* optc-save-gen.awk: Adjust array compare to use '&ptr->name[0]'
> 	instead of 'ptr->name'.


  reply	other threads:[~2022-09-08 16:23 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 [this message]
2022-09-08 18:01   ` Martin Liška
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=f3398a7e-5900-f259-68ca-701a764d3e9f@redhat.com \
    --to=jason@redhat.com \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=mliska@suse.cz \
    --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).