View | Details | Return to bug 84463
Collapse All | Expand All

(-)gcc/cp/typeck.c.jj (-1 / +3 lines)
Lines 5900-5906 cp_build_addr_expr_1 (tree arg, bool str Link Here
5900
      && (val = get_base_address (arg))
5900
      && (val = get_base_address (arg))
5901
      && COMPLETE_TYPE_P (TREE_TYPE (val))
5901
      && COMPLETE_TYPE_P (TREE_TYPE (val))
5902
      && INDIRECT_REF_P (val)
5902
      && INDIRECT_REF_P (val)
5903
      && TREE_CONSTANT (TREE_OPERAND (val, 0)))
5903
      && TREE_CONSTANT (TREE_OPERAND (val, 0))
5904
      && (TREE_CODE (maybe_constant_value (TREE_OPERAND (val, 0)))
5905
	  == INTEGER_CST))
5904
    {
5906
    {
5905
      tree type = build_pointer_type (argtype);
5907
      tree type = build_pointer_type (argtype);
5906
      return fold_convert (type, fold_offsetof_1 (arg));
5908
      return fold_convert (type, fold_offsetof_1 (arg));
(-)gcc/testsuite/g++.dg/cpp0x/constexpr-84463.C.jj (+22 lines)
Line 0 Link Here
1
// PR c++/84463
2
// { dg-do compile { target c++11 } }
3
4
struct S { int r; const unsigned char s[5]; };
5
static constexpr S a[] = { { 0, "abcd" } };
6
struct T { const unsigned char s[5]; };
7
static constexpr T b[] = { { "abcd" } };
8
9
constexpr int
10
foo (const unsigned char *x)
11
{
12
  return x[0];
13
}
14
15
constexpr static const S *j = &a[0];
16
constexpr static const int k = j->s[0];
17
constexpr static int l = foo (a[0].s);
18
constexpr static int m = foo (j->s);
19
constexpr static const T *n = &b[0];
20
constexpr static const int o = n->s[0];
21
constexpr static int p = foo (b[0].s);
22
constexpr static int q = foo (n->s);

Return to bug 84463