public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Tim Song <t.canens.cpp@gmail.com>
Cc: Patrick Palka <ppalka@redhat.com>,
	libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [committed] libstdc++: std::make_signed_t<cv bool> should be ill-formed
Date: Mon, 10 Oct 2022 15:05:16 +0100	[thread overview]
Message-ID: <CACb0b4ntUFWaCvX_xOoBi_q0kQkHve-8B2ng7qi7g5gNC1F4+w@mail.gmail.com> (raw)
In-Reply-To: <CAPQZVxtXObqvQj1M+Z5J_kQM_6N9ENbumCp98X-eLuyxgQQVNg@mail.gmail.com>

On Mon, 10 Oct 2022 at 14:50, Tim Song via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> On Mon, Oct 10, 2022 at 8:09 AM Patrick Palka via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > On Mon, 10 Oct 2022, Jonathan Wakely via Libstdc++ wrote:
> >
> > > Tested powerpc64le-linux. Pushed to trunk.
> > >
> > > -- >8 --
> > >
> > > Currently we only reject std::make_signed_t<bool> but not cv bool.
> > > Similarly for std::make_unsigned_t<cv bool>.
> > >
> > > As well as making those ill-formed, this adds a requires-clause to the
> > > make_signed and make_unsigned primary templates. This makes
> > > non-integral, non-enum cases fail immediately with a clear error, rather
> > > than giving an error about __make_signed_selector<T, false, false> being
> > > incomplete.
> >
> > IIUC the requires-clause turns what was once a hard error into a SFINAE
> > error, so e.g. for
> >
> >   template<class T> typename make_signed<T>::type f(int);
> >   template<class T> void f(...);
> >   int main() { f<void>(0); }
> >
> > the call to f would previously be rejected due to an error outside the
> > immediate context about incomplete __make_signed_selector, and now with
> > the requires-clause resolves to the second overload.  I wonder if this
> > new behavior is conforming -- the examples in [structure.specifications]
> > of how to implement 'Mandates' suggest that a failed 'Mandates' should
> > yield a hard error?
>
> I'm also concerned about the inability to name make_signed<X> in a
> context that doesn't require its instantiation (e.g.,
> conditional_t<is_integral_v<T>, make_signed<T>,
> type_identity<T>>::type). That seems a plausible use case, and
> breaking it doesn't seem great to me (conformance aside).

Ah yes, that's a problem.

We could fix it like this:

  template<typename _Tp>
    struct make_unsigned;

  template<typename _Tp>
#if __cpp_concepts
    requires is_integral<_Tp>::value || __is_enum(_Tp)
    struct make_unsigned<_Tp>
#else
    struct make_unsigned
#endif
    { typedef typename __make_unsigned_selector<_Tp>::__type type; };

  But that doesn't really improve the diagnostic much. It's simpler
just to revert the addition of the constraints.


  reply	other threads:[~2022-10-10 14:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 11:20 Jonathan Wakely
2022-10-10 13:09 ` Patrick Palka
2022-10-10 13:49   ` Tim Song
2022-10-10 14:05     ` Jonathan Wakely [this message]
2022-10-10 20:38       ` Jonathan Wakely

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=CACb0b4ntUFWaCvX_xOoBi_q0kQkHve-8B2ng7qi7g5gNC1F4+w@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    --cc=t.canens.cpp@gmail.com \
    /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).