Issue |
126299
|
Summary |
[[clang::require_explicit_initialization]] inconsistent with constructability traits (problem under -Werror)
|
Labels |
clang
|
Assignees |
|
Reporter |
higher-performance
|
Someone pointed out that `[[clang::require_explicit_initialization]]` doesn't interact well with the constructability traits:
```
// -Werror=uninitialized-explicit-init
#include <type_traits>
template<class T, bool = std::is_default_constructible<T>::value>
struct DefaultValue {
static void Get() { }
};
template<class T>
struct DefaultValue<T, true> {
static T Get() {
return T();
}
};
struct S {
int x [[clang::require_explicit_initialization]];
};
int main() {
DefaultValue<S>::Get();
}
```
The problem is exacerbated under `-Werror` (which is precisely the desired flag here) because there is no way for code to know the truth about constructability.
On the other hand, when the attribute is a warning, then constructability technically isn't affected, and the warning can be suppressed. But I'm not sure we want `-W` to affect the trait behaviors, either.
I don't know what to do here, but I wanted to raise this issue in case we want to make any changes prior to the release of LLVM 20.
@AaronBallman
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs