<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/66182>66182</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Forward declared templates error in clang, but not in gcc / msvc
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang,
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          MichielJazzy1
      </td>
    </tr>
</table>

<pre>
    See: https://godbolt.org/z/svqjxWbYf

Code that doesn't compile with LLVM 16.0, but does compile with gcc 13.2, msvc 17.6:
If you think this is c++ compliant, how would you solve this?

```
// Vector3.h
template <class T> struct Vector2;

template <class T>
struct [[nodiscard]] Vector3
{
  public:
    Vector3() {}

    constexpr Vector3(T v) noexcept {}
        constexpr Vector3(T x, T y, T z) noexcept {}
 constexpr Vector2<T> xy() const noexcept;

  private:    
    T x = {};
        T y = {};
    T z = {};
};

// Vector3.inl
template <class T> constexpr Vector2<T>     Vector3<T>::xy() const noexcept { return Vector2<T>(x, y); }

template struct Vector3<double>;


// Vector2.h
template <class T>
struct [[nodiscard]] Vector2
{
 public:
    Vector2() noexcept =default;
    Vector2(T d)
    {
 data = d;
    };          
        constexpr Vector2(T x, T y) noexcept;

    constexpr Vector3<T> xyz(T z) const noexcept;

 private:
    T data;

    T x = {};
        T y = {};
};

// Vector2.inl

template <class T> constexpr Vector3<T> Vector2<T>::xyz(T z) const noexcept
{
        return Vector3(x, y, z);
}
template <class T> constexpr
Vector2<T>::Vector2(T x, T y) noexcept
        : x(x)
        , y(y)
{
}
template struct Vector2<double>;


// main.cpp

int main() {
    Vector2<double> foo;
 Vector3<double> tree;
    auto c = tree.xy();    
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlsuOozgUhp_GbI4agV1JYMGiUplIM-peTdSjWRrbCe5xMGOb3J6-ZUMCpJKuaqkUVPb5z_Uzm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