From: Kefu Chai Date: Thu, 24 May 2018 09:21:42 +0000 (+0800) Subject: dout: declare dpp using `decltype(auto)` instead of `auto` X-Git-Tag: v14.0.0~20^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=27768ab2726c3d0bbc19b7ef2eee3c3ee62f217b;p=ceph.git dout: declare dpp using `decltype(auto)` instead of `auto` this makes `pdpp` an alias of `dpp`, guess this ensure GCC that the returned `sub` is a constant. In file included from /home/kefu/dev/ceph/src/kv/LevelDBStore.h:25, from /home/kefu/dev/ceph/src/kv/KeyValueDB.cc:6: /home/kefu/dev/ceph/src/osd/osd_types.h: In lambda function: /home/kefu/dev/ceph/src/common/dout.h:101:75: error: the value of ‘pdpp’ is not usable in a constant expression dout_impl(pdpp->get_cct(), ceph::dout::need_dynamic(pdpp->get_subsys()), v) \ ^ /home/kefu/dev/ceph/src/common/dout.h:81:58: note: in definition of macro ‘dout_impl’ return (cctX->_conf->subsys.template should_gather()); \ ^~~ /home/kefu/dev/ceph/src/osd/osd_types.h:2992:3: note: in expansion of macro ‘ldpp_dout’ ldpp_dout(dpp, 10) << "build_prior all_probe " << all_probe << dendl; ^~~~~~~~~ /home/kefu/dev/ceph/src/common/dout.h:100:12: note: ‘pdpp’ was not declared ‘constexpr’ if (auto pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for 'this' */ \ ^~~~ /home/kefu/dev/ceph/src/common/dout.h:100:12: note: in definition of macro ‘ldpp_dout’ if (auto pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for 'this' */ \ ^~~~ Signed-off-by: Kefu Chai --- diff --git a/src/common/dout.h b/src/common/dout.h index d284995f9fa5..e0114e69dfc0 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -97,7 +97,7 @@ struct is_dynamic> : public std::true_type {}; #define lderr(cct) dout_impl(cct, ceph_subsys_, -1) dout_prefix #define ldpp_dout(dpp, v) \ - if (auto pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for 'this' */ \ + if (decltype(auto) pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for 'this' */ \ dout_impl(pdpp->get_cct(), ceph::dout::need_dynamic(pdpp->get_subsys()), v) \ pdpp->gen_prefix(*_dout)