public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104578] New: [12 Regression] accepts invalid partial  template specialization, non-type template argument depends on a template parameter
@ 2022-02-17  4:55 pinskia at gcc dot gnu.org
  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
  0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-17  4:55 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug c++/104578] [12 Regression] accepts invalid partial  template specialization, non-type template argument depends on a template parameter
  2022-02-17  4:55 [Bug c++/104578] New: [12 Regression] accepts invalid partial template specialization, non-type template argument depends on a template parameter pinskia at gcc dot gnu.org
@ 2022-02-17  5:01 ` pinskia at gcc dot gnu.org
  2022-04-06 14:44 ` [Bug c++/104578] [12 Regression][CWG1315] " jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-17  5:01 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

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

* [Bug c++/104578] [12 Regression][CWG1315] accepts invalid partial  template specialization, non-type template argument depends on a template parameter
  2022-02-17  4:55 [Bug c++/104578] New: [12 Regression] accepts invalid partial template specialization, non-type template argument depends on a template parameter pinskia at gcc dot gnu.org
  2022-02-17  5:01 ` [Bug c++/104578] " pinskia at gcc dot gnu.org
@ 2022-04-06 14:44 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-06 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12 Regression] accepts     |[12 Regression][CWG1315]
                   |invalid partial  template   |accepts invalid partial
                   |specialization, non-type    |template specialization,
                   |template argument depends   |non-type template argument
                   |on a template parameter     |depends on a template
                   |                            |parameter
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
This was changed by r12-1093, which implements https://wg21.link/cwg1315 . 
This testcase seems like exactly the sort of thing that DR1315 intended to
allow.

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

end of thread, other threads:[~2022-04-06 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17  4:55 [Bug c++/104578] New: [12 Regression] accepts invalid partial template specialization, non-type template argument depends on a template parameter pinskia at gcc dot gnu.org
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

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).