Skip to content

Non default constructible object is created and returned, somehow #42

Description

@fabiorossetto

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions