https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122690
Bug ID: 122690
Summary: [C++23] std::is_implicit_lifetime incorrectly depends
on constructor access
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: CoachHagins at gmail dot com
Target Milestone: ---
**Summary**
`std::is_implicit_lifetime` is required to be `true` for class types that have
at least one trivial eligible constructor and a trivial, non-deleted
destructor, regardless of the access of that constructor. However, the
implementation in libstdc++ returns `false` when the trivial default
constructor is `private` or `protected`. Making the constructor `public` flips
the trait to `true`. FWIW, clang with libc++ reports `true` in all three cases,
as required.
In the example below, I explicitly make the copy/move constructors non-trivial
so the only variation is in the default constructor, which is always trivial.
**Reproduction**
```c++
#include <type_traits>
class Foo {
int i;
ACCESS:
Foo() = default;
public:
Foo(int i) : i(i) { }
Foo(Foo const & that) : i(that.i) {}
Foo(Foo && that) : i(that.i) {}
};
static_assert(std::is_implicit_lifetime<Foo>::value);
int main()
{
}
```
This passes: `g++ -std=c++23 -DACCESS=public main.cpp`
This fails: `g++ -std=c++23 -DACCESS=private main.cpp`
This fails: `g++ -std=c++23 -DACCESS=protected main.cpp`
The only change is the access specifier for the explicitly defaulted default
constructor.