+2012-10-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/55081
+ * typeck2.c (store_init_value): Call fold_non_dependent_expr
+ and maybe_constant_init even for C++98.
+
2012-10-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54984
/* In C++0x constant expression is a semantic, not syntactic, property.
In C++98, make sure that what we thought was a constant expression at
- template definition time is still constant. */
- if ((cxx_dialect >= cxx0x
- || DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
- && (decl_maybe_constant_var_p (decl)
- || TREE_STATIC (decl)))
+ template definition time is still constant and otherwise perform this
+ as optimization, e.g. to fold SIZEOF_EXPRs in the initializer. */
+ if (decl_maybe_constant_var_p (decl) || TREE_STATIC (decl))
{
bool const_init;
value = fold_non_dependent_expr (value);
--- /dev/null
+// PR c++/55081
+// { dg-do compile }
+
+struct R { int field; } r;
+
+__UINTPTR_TYPE__ *
+foo ()
+{
+ static __UINTPTR_TYPE__ array[] = {
+ sizeof (char),
+ (reinterpret_cast <__UINTPTR_TYPE__>(&r.field)
+ - reinterpret_cast <__UINTPTR_TYPE__>(&r)) + 1
+ };
+ return array;
+}
+
+// { dg-final { scan-assembler-not "_ZGVZ3foovE5array" } }