Crash when inheriting with local_storage
ArekPiekarz opened this issue · 0 comments
ArekPiekarz commented
The following usage of derived te::poly with local_storage ends with a crash instead of printing "Circle":
#include "external/te/include/te.hpp"
#include <iostream>
struct Drawable : te::poly<Drawable, te::local_storage<16>> {
using te::poly<Drawable, te::local_storage<16>>::poly;
void draw(std::ostream &out) const {
te::call([](auto const &self, auto &out) { self.draw(out); }, *this, out);
}
};
struct Circle {
void draw(std::ostream &out) const {
out << "Circle\n";
}
};
void draw(Drawable const &drawable) { drawable.draw(std::cout); }
int main() {
draw(Circle{});
}
When we modify Circle to print its copy constructor:
struct Circle {
Circle() = default;
Circle(const Circle&) { std::cout << "Circle(const Circle&) ctor\n"; }
void draw(std::ostream &out) const {
out << "Circle\n";
}
};
we get spammed with Circle(const Circle&) ctor
in the console until it crashes.
Am I doing something wrong or is there a bug in te?
Environment
OS: Ubuntu 17.10 x64
Compiler: GCC 7.2 x64