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

            Bug ID: 97643
           Summary: Accepts invalid qualification conversion involving
                    array of unknown bound [P0388]
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: leni536 at gmail dot com
  Target Milestone: ---

version: g++ (Compiler-Explorer-Build) 11.0.0 20201029 (experimental)

https://godbolt.org/z/a8sKr3

In C++20 the following code is ill-formed, but gcc accepts it:

void foo(int (*arr)[10]);

void bar(int (*arr)[]) {
    int (* ptr)[10];
    int (** ptr2)[] = &ptr; // not allowed
    *ptr2 = arr;
    foo(ptr);
}

The conversion happens from T1 = int (**)[10] to T2 = int (**)[] .

The cv-decomposition of the two types are:
T1 = pointer to | pointer to | array of 10               | int
T2 = pointer to | pointer to | array of unknown bound of | int

The cv-combined type is:
T3 = pointer to | const pointer to | array of unknown bound of | int
= int (*const*)[]

Reply via email to