mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 13:11:04 +01:00
Fix infinite recursion in PrintList. (#642)
Also make `Stack`'s single-argument constructor explicit, which would have helped catch this at compile time.
This commit is contained in:
@@ -57,7 +57,7 @@ struct Stack {
|
||||
Stack() { head = nullptr; }
|
||||
|
||||
// Creates an instance containing just `x`.
|
||||
Stack(T x) : Stack() { Push(x); }
|
||||
explicit Stack(T x) : Stack() { Push(x); }
|
||||
|
||||
// Pushes `x` onto the top of the stack.
|
||||
void Push(T x) { head = new ListNode<T>(x, head); }
|
||||
|
||||
Reference in New Issue
Block a user