http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-06 
11:00:19 UTC ---
Better testcase:

// PR c++/48911
// { dg-do compile }
// { dg-options "-std=c++0x" }

struct A
{
  constexpr A () : a (6) {}
  int a;
};

int
main ()
{
  constexpr int a[1] = { 0 };
  constexpr int i = a[0];
  constexpr int b[1] = { };
  constexpr int j = b[0];
  constexpr char c[2] = "a";
  constexpr char k = c[1];
  constexpr char d[2] = "";
  constexpr char l = d[1];
  constexpr wchar_t e[2] = L"a";
  constexpr wchar_t m = e[1];
  constexpr wchar_t f[2] = L"";
  constexpr wchar_t n = f[1];
  constexpr A g[2] = { A () };
  constexpr A o = g[0];
  constexpr A p = g[1];
}

which covers also the case where ary is not CONSTRUCTOR, but STRING_CST.
I think we want to to the len check as done right now, but if index is above
len, we shouldn't error or set non-constant unconditionally, instead we should
check domain of TREE_TYPE (oldary).  If it is within the range, we want to
return zero of the appropriate type for PODs, not sure what exactly for
constexpr non-PODs.

Reply via email to