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

            Bug ID: 109065
           Summary: [11/12/13 Regression] Type alias combination
                    erroneously fails with "incomplete type"
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marcel.jacobse at ewetel dot net
  Target Milestone: ---

Starting with gcc 11.1, the code

template <class T> using DataAlias = int;
template <class T> struct MyUniquePtr {};

template <class T> struct Test {
    using Data = DataAlias<T>;
    MyUniquePtr<Data[]> d;
};
Test<int> test;

fails to compile with

<source>: In instantiation of 'struct Test<int>':
<source>:8:11:   required from here
<source>:6:25: error: 'Test<T>::d' has incomplete type
    6 |     MyUniquePtr<Data[]> d;
      |                         ^
<source>:2:27: note: declaration of 'struct MyUniquePtr<int []>'
    2 | template <class T> struct MyUniquePtr {};
      |                           ^~~~~~~~~~~

See for example: https://godbolt.org/z/oq9TjqKrW
I believe this to be valid C++11 through C++20 and it seems to compile just
fine with clang, MSVC and any gcc <= 10.4 that supports C++11.

A range of minor changes make it compile again, for example:
* Make DataAlias actually use T in any way, e.g.
https://godbolt.org/z/cb9dW1E6s
* Don't use an array type for d, i.e. https://godbolt.org/z/MGKPcjEz3
* Don't use the second alias level for d, i.e. https://godbolt.org/z/KaWq9Pfq8

Reply via email to