public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jason at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/114841] New: [P0522R0] partial ordering of template template parameters
Date: Wed, 24 Apr 2024 22:07:34 +0000	[thread overview]
Message-ID: <bug-114841-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114841
           Summary: [P0522R0] partial ordering of template template
                    parameters
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jason at gcc dot gnu.org
  Target Milestone: ---

Created attachment 58029
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58029&action=edit
WIP patch against r8-7277-g515f874faf4562

In the 2016 CWG discussion of making P0522R0 actually work, I proposed the
adjustment that I implemented in r7-5537-g31bfc9b9dd65ec and drafted as

<ins>* X is an invented class template with the template parameter
list of A, including default arguments, except that during partial ordering
(14.5.6.2), for each non-parameter-pack template parameter of A, the
corresponding template parameter of X has a default argument which
is compatible with any other template-argument.</ins>

In a reply, Richard Smith noted that this would wrongly accept this example:

template<typename T, typename U> struct match2;

template<template<typename A> class t1,typename T>
struct match2<t1<T>, typename t1<T>::type > { typedef int type; }; // #5        

template<template<typename B, typename C> class t2,typename T0,typename T1>
struct match2<t2<T0,T1>, typename t2<T0,T0>::type > { typedef int type; }; //
#6                                         

template <class T, class U = T> struct Q { typedef int type; };
match2<Q<int>, int> m;

and indeed GCC still chooses #6, which is questionable since t1<T> cannot
reasonably be deduced to be both t2<T0,T1> and t2<T0,T0>.

I worked on implementing this in 2017 but never finished.
His alternative suggestion was still to introduce a default argument, but
instead of having it match any other template argument, base the default on the
actual arguments, i.e. T1 or T0.  I worked on this for a while in 2017 but
didn't finish.  Now that Clang is implementing this
(https://github.com/llvm/llvm-project/pull/89807), it would be nice to finish
it up.

             reply	other threads:[~2024-04-24 22:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 22:07 jason at gcc dot gnu.org [this message]
2024-04-24 22:08 ` [Bug c++/114841] " jason at gcc dot gnu.org
2024-04-30 22:02 ` 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-114841-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).