public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104578] New: [12 Regression] accepts invalid partial  template specialization, non-type template argument depends on a template parameter
Date: Thu, 17 Feb 2022 04:55:34 +0000	[thread overview]
Message-ID: <bug-104578-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104578

            Bug ID: 104578
           Summary: [12 Regression] accepts invalid partial  template
                    specialization, non-type template argument depends on
                    a template parameter
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

While looking into PR 104567, I just happened upon some code which is rejected
by before GCC 12, MSVC, clang and ICC. I suspect it is invalid code as all
other compilers besides the trunk reject it for a similar reasons.
Take:
template <typename _TAny, int value = _TAny::param>
struct s{};

template <typename _TAny>
struct s<_TAny, _TAny::param>
{
  typedef int type;
};
struct checked_type
{
    static const int param = 0;
};

s<checked_type>::type  t;

int main()
{
    return t;
}
----- CUT ----
clang reports:
<source>:5:17: error: type of specialized non-type template argument depends on
a template parameter of the partial specialization
struct s<_TAny, _TAny::param>
                ^~~~~
<source>:14:18: error: no type named 'type' in 's<checked_type, 0>'
s<checked_type>::type  t;
~~~~~~~~~~~~~~~~~^

MSVC reports:
<source>(8): error C2753: 's<_TAny,_TAny::param>': partial specialization
cannot match argument list for primary template

ICC reports:
<source>(5): error: the template argument list of the partial specialization
includes a nontype argument whose type depends on a template parameter
  struct s<_TAny, _TAny::param>
         ^

GCC 11.2.0 reports:
<source>:5:8: error: template argument '_TAny::param' involves template
parameter(s)
    5 | struct s<_TAny, _TAny::param>
      |        ^~~~~~~~~~~~~~~~~~~~~~

GCC 12 accepts this for all levels of the C++ standard.

             reply	other threads:[~2022-02-17  4:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17  4:55 pinskia at gcc dot gnu.org [this message]
2022-02-17  5:01 ` [Bug c++/104578] " pinskia at gcc dot gnu.org
2022-04-06 14:44 ` [Bug c++/104578] [12 Regression][CWG1315] " jason at gcc dot gnu.org

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=bug-104578-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).