[Bug c++/94264] New: Array-to-pointer conversion not performed on array prvalues

ndkrempel at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Mar 23 00:21:15 GMT 2020


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

            Bug ID: 94264
           Summary: Array-to-pointer conversion not performed on array
                    prvalues
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ndkrempel at gmail dot com
  Target Milestone: ---

I think the most clearcut example is:

int main() {
  using T = int[];
  T{1, 2} == nullptr;
}

This compiles fine with clang, and is supported by the standard: the ==
operator explicitly performs array-to-pointer conversion
(https://eel.is/c++draft/expr#eq-1), and array-to-pointer conversion is
explicitly defined for rvalue arrays (https://eel.is/c++draft/expr#conv.array).

Other examples (which again all compile with clang) are:

+T{1, 2};
  Here the standard wording seems to have a minor bug, as unary "+" does not
explicitly perform the array-to-pointer conversion, and the general rubric for
applying it (https://eel.is/c++draft/expr#basic.lval-6) only applies to
glvalues as written.

T{1, 2} + 1;
  Ditto.

*(T{1, 2} + 1);
  Interesting as T{1, 2}[1] should be equivalent to this (modulo the value
category of the result, https://eel.is/c++draft/expr#sub), yet the former is
rejected by gcc and the latter accepted.


More information about the Gcc-bugs mailing list