From 3e122818a2469a62ee72d04fc97796bdebbe6d29 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Thu, 30 Sep 2021 07:12:33 +0000 Subject: [PATCH] dawn_node: Fix stack overflow with Write() In review, the variadic overload of Write() was changed, which adjusted the overload resolution priorities W.R.T the single argument overload: https://dawn-review.googlesource.com/c/dawn/+/64747/3..7/src/dawn_node/utils/Debug.h#b96 This caused the variadic overload to be picked for the single-argument case, leading to stack overflows when calling Write(). Fixed by using perfect forwarding for the single argument case of Write(). Bug: dawn:1123 Change-Id: I21ab290e9c2e4b92ab472552f809484fb7426a45 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65244 Reviewed-by: Austin Eng Reviewed-by: Corentin Wallez Commit-Queue: Ben Clayton --- src/dawn_node/utils/Debug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dawn_node/utils/Debug.h b/src/dawn_node/utils/Debug.h index 8a2f27f6f7..d9551f660b 100644 --- a/src/dawn_node/utils/Debug.h +++ b/src/dawn_node/utils/Debug.h @@ -41,7 +41,7 @@ namespace wgpu { namespace utils { template inline std::ostream& Write(std::ostream& out, const std::variant& value); template - inline std::ostream& Write(std::ostream& out, const VALUE& value); + std::ostream& Write(std::ostream& out, VALUE&& value); // Write() implementations template @@ -89,8 +89,8 @@ namespace wgpu { namespace utils { } template - std::ostream& Write(std::ostream& out, const VALUE& value) { - return out << value; + std::ostream& Write(std::ostream& out, VALUE&& value) { + return out << std::forward(value); } template