folly/ExceptionWrapper.h: avoid warning about typeid operand side effects
authorJim Meyering <meyering@fb.com>
Fri, 13 Feb 2015 17:23:08 +0000 (09:23 -0800)
committerAlecs King <int@fb.com>
Tue, 3 Mar 2015 03:20:31 +0000 (19:20 -0800)
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:

folly/ExceptionWrapper.h

index 14df3299c56a4950b789da079d58e72ebd843564..3b44e53f2d7709c6a773090e82bd5d8bfe1af3cb 100644 (file)
@@ -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 {