Description
Hi, there is thinking that it could be a bug in Clang (tried with 15 as well as trunk).
Original discussion as per
https://gcc.gnu.org/pipermail/gcc-help/2022-December/142044.html
and
https://gcc.gnu.org/pipermail/gcc-help/2022-December/142047.html
the code below reproduces the issue (GCC 12.2 -std=c++20 compiles fine, MSVC19.33 /std:c++20 compiles fine, Clang 15.0.0 and trunk -std=c++20 barf)
#include <memory>
#include <vector>
#include <optional>
struct X;
template <typename T>
struct J {
typedef typename T::x aoeu;
};
struct S {
::std::vector<::std::shared_ptr<J<X>>> v;
};
static ::std::optional<S> opt;
struct X {
typedef int x;
};
int main () {
}
Clang barfs with: incomplete type 'X' named in nested name specifier typedef typename T::x aoeu (if one makes struct X a template the textual error changes but semantics remain the same more or less)...
Interestingly if S::v is not a vector, i.e. instead of
::std::vector<::std::shared_ptr<J>> v;
v is just
::std::shared_ptr<J> v;
... then clang compiles fine.
The thoughts on GCC email list are that since no instantiation takes place (shared_ptr) then the code should compile.
As LIU Hao comments in that second link above: I think this is a bug in Clang. Instantiation of shared_ptr<T<U>>
is not meant to instantiate T<U>
. Your code actually compiles fine if the definition of J
was not provided.
Kind regards
Leon