I have the following code snippet:
#include <vector>
struct X {
std::vector<X> v;
X(std::vector<X> vec) : v{vec} {}
};
int main() {
X{{}};
}
Compiling and running this snippet locally results in a stack overflow originating from X's constructor. Inspection with gdb shows me that the constructor is somehow recursively calling itself, but that doesn't make sense because I'm not calling it recursively. Why might this be happening and what can I do to fix it?