https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101937

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Clang accepts this:

struct S {
  enum { _M_indent = 4 };
};

int f(S s)
{
  const char str[s._M_indent + 1] = "    ";
  return sizeof(str);
}

But rejects the same program with a reference parameter:

struct S {
  enum { _M_indent = 4 };
};

int f(S& s)
{
  const char str[s._M_indent + 1] = "    ";
  return sizeof(str);
}


This will fix it for clang:

--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -625,8 +625,8 @@ namespace
        // If this isn't the first line, indent
        if (ctx._M_column == 1 && !ctx._M_first_line)
          {
-           const char spacing[ctx._M_indent + 1] = "    ";
-           print_raw(ctx, spacing, ctx._M_indent);
+           const char spacing[PrintContext::_M_indent + 1] = "    ";
+           print_raw(ctx, spacing, PrintContext::_M_indent);
          }

        int written = fprintf(stderr, "%.*s", (int)length, word);

Reply via email to