On Fri, 13 Sept 2024 at 12:52, Jonathan Wakely <jwakely....@gmail.com> wrote:
>
> On Fri, 13 Sept 2024 at 10:30, Sunil Kumar Dora
> <sunilkumar.d...@blackfigtech.com> wrote:
> >
> > Dear GCC Community,
> > I am currently encountering an issue with the -Wrange-loop-construct 
> > warning in GCC version 14, as well as in earlier versions. It appears that 
> > the warning is triggered incorrectly for certain loop constructs.
> > Issue Details:
> > I have tested the following code, which produces a warning with GCC/G++ 
> > suggesting the use of a reference:
> > Test Code:
> > Link to test code on Godbolt<https://godbolt.org/z/xM4K6s34E> (GCC produces 
> > warning)
> > For comparison, here is how Clang 18 handles the same code:
> >  Link to Clang result on Godbolt<https://godbolt.org/z/aYTxP7K9o>  (Clang 
> > handles correctly)
> > It seems that GCC/G++ might be checking for trivial copyability rather than 
> > trivial copy-constructibility, which could be contributing to the issue.
> > Questions:
> >
> >   1.  Is this a known issue with the -Wrange-loop-construct option?
> >   2.  Am I possibly overlooking something in my usage of this option?
> >
> > If this is a known issue, or if you require additional information, please 
> > let me know. Additionally, if it would be appropriate to create a formal 
> > bug report to track this, I would be happy to do so.
>
> Please file a bug report (and please don't send a mail to both the gcc
> and gcc-help lists, very few mails belong on both lists at the same
> time - just pick one).
>
> I'm not sure what the heuristic is for triggering the warning, but I
> agree that testing for trivially copy constructible might be better
> here.

This is the condition, so it is indeed using trivially copyable:

  /* Since small trivially copyable types are cheap to copy, we suppress the
     warning for them.  64B is a common size of a cache line.  */
  if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST
      || (tree_to_uhwi (TYPE_SIZE_UNIT (type)) <= 64
      && trivially_copyable_p (type)))
    return;





>
>
> > Thank you very much for your assistance and guidance.
> >
> > Thanks,
> > Sunil Dora

Reply via email to