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

            Bug ID: 84930
           Summary: Brace-closed initialization of cstring
                    (i.e."abcdefghi") to coresponding aggregate types
                    fails in certain situation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hotguest1 at hotmail dot com
  Target Milestone: ---

We can do this in both GCC and clang

        std::array<std::array<char, 10>, 2> arr_from_cstr1{{
                {{"abcdefghi"}}, {{"abcdefghi"}}
        }};

        std::array<const char[10], 2> arr_from_cstr2{{
                {"abcdefghi"}, {"abcdefghi"}
        }};

        std::vector<std::array<char, 10> > vec_from_direct{{
                {{ 'a','b','c','d','e','f','g','h','i','\0' }},
                {{ 'a','b','c','d','e','f','g','h','i','\0' }}
        }};

        std::vector vec_from_ctor{{
                std::array<char, 10>{ {"abcdefghi"} },
                std::array<char, 10>{ {"abcdefghi"} }
        }};

We can't do this in GCC but can do in clang

        std::vector<std::array<char,10> > vec_from_ctr1{{
                {{"abcdefghi"}}, {{"abcdefghi"}}
        }};

        struct A {
          std::array<char, 10> x; 
          A(std::array<char, 10> arr) : x(arr) {}
        };
        A struct_from_ctr1{ {{"abcdefghi"}} };

You may see the error details in CE (tested with gcc 7.3):
https://godbolt.org/g/zV6dHd

I'm sorry that I can't describe the scenario good enough.

Reply via email to