[all-commits] [llvm/llvm-project] 7d58c9: [Clang] Don't consider default constructors inelig...

Roy Jacobson via All-commits all-commits at lists.llvm.org
Mon Dec 5 13:02:51 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7d58c95635cce63ce6acd43c953b57f10bf5c686
      https://github.com/llvm/llvm-project/commit/7d58c95635cce63ce6acd43c953b57f10bf5c686
  Author: Roy Jacobson <roi.jacobson1 at gmail.com>
  Date:   2022-12-05 (Mon, 05 Dec 2022)

  Changed paths:
    M clang/lib/AST/DeclCXX.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/SemaCXX/constrained-special-member-functions.cpp

  Log Message:
  -----------
  [Clang] Don't consider default constructors ineligible if the more constrained constructor is a template

Partially solves https://github.com/llvm/llvm-project/issues/59206:

We now mark trivial constructors as eligible even if there's a more constrained templated default constructor. Although technically non-conformant, this solves problems with pretty reasonable uses cases like
```
template<int n>
struct Foo {
	constexpr Foo() = default;

	template<class... Ts>
	Foo(Ts... vals) requires(sizeof...(Ts) == n) {}
};
```
where we currently consider the default constructor to be ineligible and therefor inheriting/containing classes have non trivial constructors. This is aligned with GCC: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c75ebe76ae12ac4020f20a24f34606a594a40d15

This doesn't change `__is_trivial`. Although we're technically standard conformant in this regard, GCC/MSVC exhibit different behaviors that seem to make more sense. An issue has been filed to CWG and we await their response.

Reviewed By: erichkeane, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D139038




More information about the All-commits mailing list