From cf6ef289c712ccd021fd9d66dc4cc509fc13c725 Mon Sep 17 00:00:00 2001 From: Ondrej Lehecka Date: Tue, 28 Mar 2017 18:58:12 -0700 Subject: [PATCH] Cursor::read() initializes return value Summary: If the compiler doesn't see thru the call to tryRead which always initializes the val variable, it will emit the following error. I was getting error when compiling my android project: error: 'val' may be used uninitialized in this function [-Werror=maybe-uninitialized] This should not have a negative perf impact as smart compilers which inline call to tryRead can elliminate the initialization. Reviewed By: djwatson Differential Revision: D4790864 fbshipit-source-id: f353cfe54ca4d056b6ddfc075d00580c9f2d391e --- folly/io/Cursor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/folly/io/Cursor.h b/folly/io/Cursor.h index 516b1039..5a8a32a6 100644 --- a/folly/io/Cursor.h +++ b/folly/io/Cursor.h @@ -227,7 +227,7 @@ class CursorBase { template T read() { - T val; + T val{}; if (!tryRead(val)) { std::__throw_out_of_range("underflow"); } -- 2.34.1