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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot 
gnu.org

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
There is code to handle this case in instantiate_class_template_1 but it's not
quite correct.  It assumes that the the array element type has been completed
which in this case isn't a safe assumption.  Let me fix this.

A slightly simpler test case is below:

$ cat xx.cpp && gcc -S -Wall -Wextra -Wpedantic xx.cpp
template <typename>
struct container
{
  struct elem {
    unsigned u;
  };
  struct incomplete {
    int x;
    elem array[];
  };
};

unsigned f (container<void>::incomplete* i)
{
  return i->array [0].u;
}
xx.cpp: In instantiation of ‘struct container<void>::incomplete’:
xx.cpp:15:11:   required from here
xx.cpp:9:16: error: ‘container< <template-parameter-1-1> >::incomplete::array’
has incomplete type
     elem array[];
                ^
xx.cpp:9:16: error: invalid use of array with unspecified bounds

Reply via email to