http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60955
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- Perhaps also this special case could also be removed by using TREE_NO_WARNING. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c91612c..d8374d9 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6291,7 +6291,10 @@ maybe_warn_about_useless_cast (tree type, tree expr, tsubst_flags_t complain) if (warn_useless_cast && complain & tf_warning) { - if (REFERENCE_REF_P (expr)) + /* In C++14 mode, this interacts badly with force_paren_expr. And it + isn't necessary in any mode, because the code below handles + glvalues properly. For 4.9, just skip it in C++14 mode. */ + if (cxx_dialect < cxx1y && REFERENCE_REF_P (expr)) expr = TREE_OPERAND (expr, 0);