[llvm-bugs] [Bug 38043] New: Explicit array initialization in an initializer list

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 3 11:04:57 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38043

            Bug ID: 38043
           Summary: Explicit array initialization in an initializer list
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zahira.ammarguellat at intel.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Let's consider this test case:

#include <stdio.h>

struct foo {
  int i;
  foo() : i(23) {}
};

struct goo {
  goo() {}
  goo(const goo & other);
  foo _lala[2];
};

goo::goo(const goo & other)
  : _lala(other._lala)
{
}

int main()
{
  goo z;
  if (z._lala[0].i == 23)
    puts("passed");
  else
    puts("failed");
  return 0;
}

GCC compiles this.
CL and CLANG both generate an error.

Clang's error message is:
error: array initializer must be an initializer list


If the community doesn't want to follow GCC and allow array initialization via
an initializer list (violation of C++), then clang should at least return the
right error message as this is misleading?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180703/159a99bc/attachment.html>


More information about the llvm-bugs mailing list