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
template <class T>
T read() {
- T val;
+ T val{};
if (!tryRead(val)) {
std::__throw_out_of_range("underflow");
}