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. Thank you very much for your assistance and guidance. Thanks, Sunil Dora
Attachment:
test.cpp.docx
Description: test.cpp.docx