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 <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-09-30 07:12:33 +00:00 committed by Dawn LUCI CQ
parent 4d2bc396ea
commit 3e122818a2
1 changed files with 3 additions and 3 deletions

View File

@ -41,7 +41,7 @@ namespace wgpu { namespace utils {
template <typename... TYS>
inline std::ostream& Write(std::ostream& out, const std::variant<TYS...>& value);
template <typename VALUE>
inline std::ostream& Write(std::ostream& out, const VALUE& value);
std::ostream& Write(std::ostream& out, VALUE&& value);
// Write() implementations
template <typename T>
@ -89,8 +89,8 @@ namespace wgpu { namespace utils {
}
template <typename VALUE>
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>(value);
}
template <typename FIRST, typename... REST>