[clang] Include [[clang::require_explicit_initialization]] warnings in system headers (PR #141133)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue May 27 12:15:57 PDT 2025


zygoloid wrote:

There are [techniques](https://github.com/carbon-language/carbon-lang/blob/69ab97d7167146ae1deea662126af66f8f5523a2/common/struct_reflection.h#L74) for determining the number of fields in an aggregate type `T` by attempting to initialize with `T{}` then `T{arg}` then `T{arg, arg}`, and so on (with an `arg` that converts to anything), until the initialization fails. Such techniques might in principle show up in a system header (eg, boost probably has this somewhere).

However, any such code should be in an unevaluated operand, so as long as this warning is suppressed in unevaluated operands I think it's fine for it to be enabled in system headers. (For extra assurance, can we make this a `DiagRuntimeBehavior` to also suppress it in unreachable code?)

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


More information about the cfe-commits mailing list