Re: EXTERNAL-Re: Inquiry Regarding -Wrange-loop-construct Warning Behavior in GCC 14

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jonathan,
Thank you for your advice. I will ensure to use only one email address for future communications.
I’ve also created a bug report to track this issue: GCC Bug Report 116731<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116731>.
Best regards,
Sunil Dora

________________________________
From: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
Sent: Friday, September 13, 2024 5:24 PM
To: Sunil Kumar Dora <sunilkumar.dora@xxxxxxxxxxxxxxxx>
Cc: gcc-help@xxxxxxxxxxx <gcc-help@xxxxxxxxxxx>; gcc@xxxxxxxxxxx <gcc@xxxxxxxxxxx>; Naveen G <naveen.gowda@xxxxxxxxxxxxxxxx>; Sundeep Kokkonda <sundeep.kokkonda@xxxxxxxxxxxxxxxx>
Subject: EXTERNAL-Re: Inquiry Regarding -Wrange-loop-construct Warning Behavior in GCC 14

[You don't often get email from jwakely.gcc@xxxxxxxxx. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.


On Fri, 13 Sept 2024 at 12:52, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
>
> On Fri, 13 Sept 2024 at 10:30, Sunil Kumar Dora
> <sunilkumar.dora@xxxxxxxxxxxxxxxx> 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://ind01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgodbolt.org%2Fz%2FxM4K6s34E&data=05%7C02%7Csunilkumar.dora%40blackfigtech.com%7Cbd377c811e9b4600c9c308dcd3eae803%7C75dd016f4b8642d99a4d6df5b9790019%7C0%7C0%7C638618253087059678%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=P7ryWtQbijYZdgAuW14%2Belu5em4U4ixYhNyTaR2k7yU%3D&reserved=0<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://ind01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgodbolt.org%2Fz%2FaYTxP7K9o&data=05%7C02%7Csunilkumar.dora%40blackfigtech.com%7Cbd377c811e9b4600c9c308dcd3eae803%7C75dd016f4b8642d99a4d6df5b9790019%7C0%7C0%7C638618253087083657%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=JACp8f%2BCy4YG9jMeOcYEpJZvxp0plmF3rz7a2rdGdBY%3D&reserved=0<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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux