From: leon zadorin <leonleon77@gmail.com>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: which compiler is right (either to compile or to barf)...
Date: Thu, 1 Dec 2022 15:51:58 +1100 [thread overview]
Message-ID: <CAPpySAbkd8_tZ2DXBJbbgaAWYtrEXoi65Litt16ApVNWeTvATw@mail.gmail.com> (raw)
[-- 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.
next reply other threads:[~2022-12-01 4:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 4:51 leon zadorin [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPpySAbkd8_tZ2DXBJbbgaAWYtrEXoi65Litt16ApVNWeTvATw@mail.gmail.com \
--to=leonleon77@gmail.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).