which compiler is right (either to compile or to barf)...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

I would be interested to hear the opinions of C++ standard experts on which
compiler is correctly dealing with the below code (GCC 12.2 -std=c++20
 compiles fine, MSVC19.33 /std:c++20 compiles fine, Clang 15.0.0 -std=c++20
barfs)


#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

Interestingly if S::v is not a vector, i.e. instead of
::std::vector<::std::shared_ptr<J<X>>> v;
v is just
::std::shared_ptr<J<X>> v;

... then clang compiles fine.

Also, if optional is replaced with say unique_ptr, clang also builds fine.

I would be interested in being educated on the standard (of which I am not
a lawyer :) ) what would be the correctly mandated behavior?

Kind regards
Leon.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux