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

            Bug ID: 108669
           Summary: [diagnostic] std::vector of incomplete type has member
                    referenced
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldalessandro at gmail dot com
  Target Milestone: ---

In the following code example, I perform a value initialization of a
std::vector of incomplete type.

-
    #include <vector>

    struct B;

    struct A {
        std::vector<B> _;
    };

    A a{};  // <--here

    struct B {};
-

https://godbolt.org/z/ab5Erqc1n

This should run afoul of the second half of
https://eel.is/c++draft/vector#overview-4. "T shall be complete before any
member of the resulting specialization of vector is referenced."

I honestly don't know if that "shall" implies this is ill-formed or undefined
behavior. However, this test case has started to be rejected in clang-15 for
-std=C++20 code specifically, thus it would be a very helpful quality-of-life
improvement if gcc could issue a diagnostic for this problem as well.

Reply via email to