public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* which compiler is right (either to compile or to barf)...
@ 2022-12-01  4:51 leon zadorin
  2022-12-01  9:35 ` LIU Hao
  0 siblings, 1 reply; 13+ messages in thread
From: leon zadorin @ 2022-12-01  4:51 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]

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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-12-02 10:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01  4:51 which compiler is right (either to compile or to barf) leon zadorin
2022-12-01  9:35 ` LIU Hao
2022-12-01 23:26   ` leon zadorin
2022-12-01 23:54     ` Jonathan Wakely
2022-12-01 23:56       ` Jonathan Wakely
2022-12-02  0:17       ` leon zadorin
2022-12-02  6:37         ` LIU Hao
2022-12-02  7:18           ` leon zadorin
2022-12-02  7:22             ` leon zadorin
2022-12-02  7:45             ` LIU Hao
2022-12-02  8:34               ` leon zadorin
2022-12-02  9:16                 ` leon zadorin
2022-12-02 10:50                   ` leon zadorin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).