aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-08-23 16:14:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-08-23 16:14:47 +0200
commit5c3af4220dfccfd4c381de575620a41966aa3e4f (patch)
treef965632560a50f5f6549239180bfbebd5ca7f02a
parentd030838df4f5bd2dbb94ea4adc0261d21f7f6eee (diff)
Clear data in target::data() modifiers
Currently we may end up resetting the data during the rule ambiguity detection.
-rw-r--r--libbuild2/target.hxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index de17fa8..21b5dab 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -720,7 +720,8 @@ namespace build2
typename std::enable_if<std::is_trivially_destructible<T>::value,T&>::type
data (R&& d) const
{
- assert (sizeof (T) <= data_size && data_dtor == nullptr);
+ assert (sizeof (T) <= data_size);
+ clear_data ();
return *new (&data_pad) T (forward<R> (d));
}
@@ -730,7 +731,8 @@ namespace build2
typename std::enable_if<!std::is_trivially_destructible<T>::value,T&>::type
data (R&& d) const
{
- assert (sizeof (T) <= data_size && data_dtor == nullptr);
+ assert (sizeof (T) <= data_size);
+ clear_data ();
T& r (*new (&data_pad) T (forward<R> (d)));
data_dtor = [] (void* p) {static_cast<T*> (p)->~T ();};
return r;