Consider std::latch
[thread.latch.class]:
namespace std {
class latch {
public:
static constexpr ptrdiff_t max() noexcept;
constexpr explicit latch(ptrdiff_t expected);
~latch();
latch(const latch&) = delete;
latch& operator=(const latch&) = delete;
void count_down(ptrdiff_t update = 1);
bool try_wait() const noexcept;
void wait() const;
void arrive_and_wait(ptrdiff_t update = 1);
private:
ptrdiff_t counter; // exposition only
};
}
Note that destructor is present. This means that this should hold:
static_assert(std::is_trivially_destructible_v<std::latch> == false);
However, it is opposite for the implementations (MSVC STL, libstdc++, libc++): https://godbolt.org/z/6s8173zTc
Is this:
- Implementation freedom (implementations are correct,
is_trivially_destructible_v
may betrue
orfalse
) - Implementation defect in every implementation (implementation should have non-trivial destructor for
std::latch
) - Standard defect (Standard shouldn't have specified
std::latch
to have non-trivial destructor)
?