From: Jim Meyering Date: Fri, 13 Feb 2015 17:23:08 +0000 (-0800) Subject: folly/ExceptionWrapper.h: avoid warning about typeid operand side effects X-Git-Tag: v0.27.0~40 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a3259f635f9b2fb5a109672c0f16d4a497fa3b67;p=folly.git folly/ExceptionWrapper.h: avoid warning about typeid operand side effects Summary: * folly/ExceptionWrapper.h (class_name): Clang is not yet smart enough to see that there is no harm in dereferencing an "item_" that we've just verified is non-NULL. Accommodate it, to avoid this: ./folly/ExceptionWrapper.h:199:30: error: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Werror,-Wpotentially-evaluated-expression] return demangle(typeid(*item_)); ^ Test Plan: Run these commands and note there are fewer errors than before: fbconfig --clang --with-project-version=clang:dev -r folly && fbmake dbgo Reviewed By: mhorowitz@fb.com Subscribers: trunkagent, yfeldblum, folly-diffs@ FB internal diff: D1848327 Tasks: 6244745 Signature: t1:1848327:1423869597:a58c9e9e3671befb78ae07fbd274a13d08ffb2a7 Blame Revision: --- diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index 14df3299..3b44e53f 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -196,7 +196,8 @@ class exception_wrapper { fbstring class_name() const { if (item_) { - return demangle(typeid(*item_)); + auto& i = *item_; + return demangle(typeid(i)); } else if (eptr_) { return ename_; } else {