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

            Bug ID: 123305
           Summary: References to array of unknown bound initialized with
                    an empty braced-init-list are accepted
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gulackeg at gmail dot com
  Target Milestone: ---

Test code:

    // https://godbolt.org/z/jsMddqP9n

    using T = int[];

    // - ✅ GCC: error: zero-size array 't1'
    // - ✅ Clang: warning: zero size arrays are an extension
    //   [-Wzero-length-array]
    // - ✅ EDG: error: an empty initializer is invalid for an array with
    //   unspecified bound
    // - ✅ MSVC: error C2466: cannot allocate an array of constant size 0
    T t1 = {};

    // - ❌ GCC: OK
    // - ✅ Clang: warning: zero size arrays are an extension
    //   [-Wzero-length-array]
    // - ✅ EDG: error: an empty initializer is invalid for an array with
    //   unspecified bound
    // - ✅ MSVC:
    //   - error C2440: 'initializing': cannot convert from 'initializer
    //     list' to 'T (&&)'
    //   - note: Reason: cannot convert from 'initializer list' to 'T'
    //   - note: An array of unknown size cannot be initialized with an
    //     empty initializer list
    T &&t2 = {};

Reply via email to