+2009-11-12 Jason Merrill <jason@redhat.com>
+
+ PR c++/42013
+ * call.c (build_conditional_expr): Don't fold a TREE_SIDE_EFFECTS
+ COND_EXPR in unevaluated context.
+
2009-11-12 Jan Hubicka <jh@suse.cz>
* decl2.c (constrain_visibility): Clear WEAK and COMMON flags.
}
valid_operands:
- result = fold_if_not_in_template (build3 (COND_EXPR, result_type, arg1,
- arg2, arg3));
+ result = build3 (COND_EXPR, result_type, arg1, arg2, arg3);
+
+ if (cp_unevaluated_operand && TREE_SIDE_EFFECTS (result))
+ /* Avoid folding a ?: of two calls within decltype (c++/42013). */;
+ else
+ result = fold_if_not_in_template (result);
+
/* We can't use result_type below, as fold might have returned a
throw_expr. */
+2009-11-12 Jason Merrill <jason@redhat.com>
+
+ PR c++/42013
+ * g++.dg/cpp0x/decltype19.C: New.
+
2009-11-11 Jason Merrill <jason@redhat.com>
PR c++/39131
--- /dev/null
+// PR c++/42013
+
+template<typename _Tp>
+ _Tp
+declval();
+
+template<typename _Tp, typename _Up>
+ struct common_type
+ {
+ typedef __decltype(true ? declval<_Tp>() : declval<_Up>()) typet;
+ typedef __decltype(false ? declval<_Tp>() : declval<_Up>()) typef;
+ };
+
+template<typename, typename> struct is_same;
+
+template<typename _Tp> struct is_same<_Tp, _Tp> { typedef _Tp type; };
+
+void f()
+{
+ typedef common_type<int, const int>::typet typet;
+ typedef common_type<int, const int>::typef typef;
+
+ typedef is_same<typet, typef>::type type;
+}