| Issue |
66182
|
| Summary |
Forward declared templates error in clang, but not in gcc / msvc
|
| Labels |
clang,
new issue
|
| Assignees |
|
| Reporter |
MichielJazzy1
|
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 = ""
};
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();
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs