On Mon, May 13, 2013 at 03:25:11PM -0400, Jason Merrill wrote: > In this testcase, since one of the overloads takes a pointer, we > need to check whether the argument is a valid null pointer constant. > In C++11 only an integer literal can be a null pointer constant of > integral type, but in C++03 we need to handle other integer constant > expressions. Here we were passing the call expression into > value_dependent_expression_p, but in C++03 mode that function > expects its argument to be a constant expression, and the expression > wasn't filtered out by potential_constant_expression. The simplest > solution is to just check TREE_SIDE_EFFECTS since in C++03 mode an > expression with side-effects can't be a constant expression (unlike > in C++11, where constexpr function substitution can produce a > constant expression from one with TREE_SIDE_EFFECTS).
What about the 4 other maybe_constant_value on fold_non_dependent_expr_sfinae (something, tf_none) calls in typeck.c (two for -Wdiv-by-zero and two for shift diagnostics)? Should that be if (cxx_dialect >= cxx0x || !TREE_SIDE_EFFECTS (t)) guarded (or wrapped into some helper function that will do all of tree some_good_name (tree t) { if (cxx_dialect < cxx0x && TREE_SIDE_EFFECTS (t)) return t; t = fold_non_dependent_expr_sfinae (t, tf_none); return maybe_constant_value (t); } Plus there is one guarded by ENABLE_CHECKING in pt.c. Jakub