public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ken Matsui <kmatsui@cs.washington.edu>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: "François Dumont" <frs.dumont@gmail.com>,
	gcc@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [GSoC] Conflicted Built-in Trait Name
Date: Mon, 27 Mar 2023 14:55:56 -0700	[thread overview]
Message-ID: <CAML+3pV=Lp_iwXnxeFLZB9sdJc2u8RK0-KGMeNB1Sst4p3028g@mail.gmail.com> (raw)
In-Reply-To: <CAH6eHdTyadXW0m2eaig=6i=L-yCvhbt5Cr3ZQU0czEogCZXStw@mail.gmail.com>

Oh! Thank you!

On Mon, Mar 27, 2023 at 2:49 PM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> On Mon, 27 Mar 2023 at 22:43, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> >
> > On Mon, 27 Mar 2023 at 21:17, Ken Matsui via Libstdc++
> > <libstdc++@gcc.gnu.org> wrote:
> > >
> > > On Mon, Mar 27, 2023 at 10:33 AM François Dumont <frs.dumont@gmail.com> wrote:
> > > >
> > > >
> > > > On 26/03/2023 04:01, Ken Matsui via Libstdc++ wrote:
> > > > > On Sat, Mar 25, 2023 at 5:38 AM Marc Glisse <marc.glisse@inria.fr> wrote:
> > > > >> On Sat, 25 Mar 2023, Ken Matsui via Gcc wrote:
> > > > >>
> > > > >>> Built-in trait naming simply adds two underscores (__) to the original
> > > > >>> trait name. However, the same names are already in use for some
> > > > >>> built-in traits, such as is_void, is_pointer, and is_signed.
> > > > >>>
> > > > >>> For example, __is_void is used in the following files:
> > > > >>>
> > > > >>> * gcc/testsuite/g++.dg/tm/pr46567.C
> > > > >> This is a testcase, you can rename __is_void to whatever in there, it
> > > > >> doesn't matter.
> > > > >>
> > > > >>> * libstdc++-v3/include/bits/cpp_type_traits.h
> > > > >> This __is_void seems to be used in a single place in
> > > > >> include/debug/helper_functions.h, couldn't we tweak that code so __is_void
> > > > >> becomes unused and can be removed?
> > > > > That worked. Thank you!
> > > > What worked ?
> > >
> > > If you meant about the code, I sent a patch series, as you can see in
> > > the following link.
> > >
> > > https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614620.html
> > >
> > > * In the following patch, I replaced __is_void with std::is_void in
> > > helper_functions.h.
> >
> > You can't do that. std::is_void is not present in C++98 mode, but the
> > code in <debug/helper_functions.h> needs to work for C++98 mode.
> >
> > >   https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614624.html
> > > * And then, I deleted __is_void in cpp_type_traits.h.
> > >   https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614623.html
> > > * Also, I replaced __is_void with ____is_void in the testcase.
> > >   https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614625.html
> > >
> > > If you meant what tests had been done, I did the following tests
> > > because the header is under libstdc++.
> > >
> > > * make check-gcc-c++ (because the patches involve changes on GCC)
> > > * make check-target-libstdc++-v3
> > >
> > > > > So, we can remove a code in a header as long as it is not standard and
> > > > > is not used elsewhere, can't we?
> > > >
> > > > You can do anything you like as long as you run the testsuite before
> > > > presenting your patch. Here note that you'll need to run:
> > > >
> > > > make check-debug
> > > >
> > > > to run tests in _GLIBCXX_DEBUG mode which is making use of the code in
> > > > helper_functions.h.
> > > >
> > > > Clearly this usage of std::__is_void could be replaced with your builtin
> > > > by reimplementing _Distance_traits like this:
> > > >
> > > >    template<typename _Iterator,
> > > >         typename = typename std::__is_integer<_Iterator>::__type>
> > > >      struct _Distance_traits
> > > >      {
> > > >      private:
> > > >        typedef
> > > >      typename std::iterator_traits<_Iterator>::difference_type _ItDiffType;
> > > >
> > > >        typedef
> > > >      typename std::conditional<__is_void<_ItDiffType>,
> > > >                    std::ptrdiff_t, _ItDiffType>::type _DiffType;
> > > >
> > > >      public:
> > > >        typedef std::pair<_DiffType, _Distance_precision> __type;
> > > >      };
> > > >
> > > > this is untested, just to give you an idea of what your patch could be.
> > > >
> > > > François
> > >
> > > Thank you! I thought the tests that I did included the
> > > hepler_function.h header, but they don’t...? If not, I must check if
> > > std::is_void in the type_traits header was correctly used.
>
> Something like this would work:
>
> --- a/libstdc++-v3/include/debug/helper_functions.h
> +++ b/libstdc++-v3/include/debug/helper_functions.h
> @@ -66,13 +66,12 @@ namespace __gnu_debug
>       typedef
>        typename std::iterator_traits<_Iterator>::difference_type _ItDiffType;
>
> -      template<typename _DiffType,
> -              typename = typename std::__is_void<_DiffType>::__type>
> +      template<typename _DiffType, typename = const _DiffType>
>        struct _DiffTraits
>        { typedef _DiffType __type; };
>
>       template<typename _DiffType>
> -       struct _DiffTraits<_DiffType, std::__true_type>
> +       struct _DiffTraits<_DiffType, const void>
>        { typedef std::ptrdiff_t __type; };
>
>       typedef typename _DiffTraits<_ItDiffType>::__type _DiffType;

  reply	other threads:[~2023-03-27 21:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-25  7:53 Ken Matsui
2023-03-25 12:23 ` Roy Jacobson
2023-03-27 21:58   ` Jonathan Wakely
2023-03-27 22:48     ` Ken Matsui
2023-03-25 12:38 ` Marc Glisse
2023-03-26  2:01   ` Ken Matsui
2023-03-27 17:33     ` François Dumont
2023-03-27 20:16       ` Ken Matsui
2023-03-27 21:43         ` Jonathan Wakely
2023-03-27 21:49           ` Jonathan Wakely
2023-03-27 21:55             ` Ken Matsui [this message]
2023-03-28 21:29       ` Ken Matsui
2023-03-28 23:24         ` Jonathan Wakely
2023-03-28 23:33           ` Ken Matsui
2023-03-30  5:11             ` François Dumont
2023-03-30  8:33               ` Ken Matsui
2023-03-30 12:23                 ` Jonathan Wakely
2023-03-30 18:44                   ` Ken Matsui

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='CAML+3pV=Lp_iwXnxeFLZB9sdJc2u8RK0-KGMeNB1Sst4p3028g@mail.gmail.com' \
    --to=kmatsui@cs.washington.edu \
    --cc=frs.dumont@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jwakely.gcc@gmail.com \
    --cc=libstdc++@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).