te
te copied to clipboard
Non default constructible object is created and returned, somehow
Expected Behavior
See the attached minimal reproducible example. SimpleCall returns an object of type NoDefaultCtor
. Somehow, the code compiles. This doesn't make sense because how can NoDefaultCtor
be constructed. value
, which should be 7, is 0 instead.
Actual Behavior
Steps to Reproduce the Problem
#include <cstdio>
#include <https://raw.githubusercontent.com/boost-experimental/te/master/include/boost/te.hpp>
#include <cassert>
namespace te = boost::te;
struct NoDefaultCtor {
NoDefaultCtor() = delete;
int value{7};
};
struct SimpleCall {
constexpr inline auto run() {
return te::call<NoDefaultCtor>([](auto &self) {}, *this);
}
};
struct Test {};
int main() {
// Option 1 or 2 is required on some compilers
te::poly<SimpleCall> f{Test{}};
NoDefaultCtor s = f.run();
return s.value;
}
Specifications
Tried on clang 16.0.0 and GCC 10