Skip to content

Commit 2a6f52d

Browse files
committed
In some cases, optional could run a destructor without having a contained object
1 parent 59f7300 commit 2a6f52d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/tv/optional.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ struct optional_storage<T> {
102102
}
103103

104104
constexpr auto uninitialize() -> void {
105-
bounded::destroy(m_data);
105+
if (is_initialized()) {
106+
bounded::destroy(m_data);
107+
}
106108
bounded::construct_at(m_data, make_uninitialized);
107109
}
108110

0 commit comments

Comments
 (0)