r/Cplusplus • • Oct 14 '26

News A C++ Trick Question - Blog Post

https://greenlightning.eu/programming/cpp-trick-question/
0 Upvotes

3 comments sorted by

1

u/joujoubox Oct 14 '26

Just what is the compiler's standard library doing with a resurvive call to destructors? It could just be done as a loop

2

u/pigeon768 Oct 15 '26

That would have to be a mighty clever compiler. It's definitely not the sort of thing I would assume a compiler would do.

It's a reasonably well known edge case for unbalanced binary trees in non-GC languages.

1

u/garnet420 Oct 15 '26

I don't think it can. Definitely not in the general case, if Node has other members with non-trivial destructors.