Skip to content

range-loop-analysis checks for trivial copyability, rather than trivial copy-constructibility #47355

@jake-arkinstall

Description

@jake-arkinstall
Bugzilla Link 48011
Version 11.0
OS Linux
CC @dwblaikie,@devincoughlin,@randomnetcat,@pogo59,@zygoloid,@Cry-Thomas

Extended Description

On the Cpplang slack, user Wolle posted a curious warning that came from range-loop-analysis.

Here's a minimal example: https://godbolt.org/z/1cxs43. Note that without the copy assignment operator overload, the warning is not present.

The range-based for loop performs a copy construction, so that is what should be checked for.

At https://clang.llvm.org/doxygen/SemaStmt_8cpp_source.html#l02824, the check is on whether the type is trivially copyable, not whether it is trivially copy constructible, which is a weaker requirement (but the relevant one in this case). I am not intimately familiar with clang sourcecode, but I believe this to be the cause of the warning.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzergood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions