[clang] [clang] warn_{cstruct, cxxstruct}_memaccess are too agressive about initializers (PR #170577)

via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 4 02:01:15 PST 2025


serge-sans-paille wrote:

My initial motivation is based on `memset` requiring trivially copyable types [according to cpp reference](https://en.cppreference.com/w/cpp/string/byte/memset), and admittedly GCC's behavior.

I tried to dig into the standard for backing arguments, but failed to do so in a clear way, so let's move forward, as I acknowledge the argument of idiomatic code. But I don't want to miss cases where a sub-object has a non trivial default constructor as in https://godbolt.org/z/aq7PosMPa.

I can see the practical aspect of only requiring:

1. trivially default constructible type when from outside of the constructor
2. that the type matches all requirements for being default constructible except the requirement of a defaulted default constructor, when from the default constructor.

What do you think of that approach?


https://github.com/llvm/llvm-project/pull/170577


More information about the cfe-commits mailing list