public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>,
	Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Iain Sandoe <idsandoe@googlemail.com>
Subject: [committed] system.h: Include <initializer_list> in system.h unconditionally
Date: Mon, 2 May 2022 07:11:54 +0200	[thread overview]
Message-ID: <Ym9oGr8DDtPtTzCA@tucnak> (raw)
In-Reply-To: <CAH6eHdTTADarpQmtgq+fwU_UhUZCxzvgU+4GHT0OctmZ_xvTpA@mail.gmail.com>

On Sun, May 01, 2022 at 07:06:53PM +0100, Jonathan Wakely wrote:
> > >> the reason is that "gcc/analyzer/region-model.cc” uses initializer_lists, and it seems that <initializer_list>
> > >> is not transitively included by any used headers for _LIBCPP_VERSION < 4000.  I fixed that locally by
> > >> adding initializer_list into system.h (and adding INCLUDE_INITIALIZER_LIST to the top of gcc/analyzer/region-model.cc)
> > >> - with that change those versions do bootstrap and test OK***
> > >
> > > From what I can see, with libstdc++ it works because <utility> which is
> > > included by system.h includes <initializer_list>.
> > > If I rename initializer_list in analyzer/region-model.ii to initializer_listx, I
> > > also get:
> > > ../../gcc/analyzer/region-model.cc: In function ‘void ana::selftest::test_binop_svalue_folding()’:
> > > ../../gcc/analyzer/region-model.cc:4966:48: error: deducing from brace-enclosed initializer list requires ‘#include <initializer_list>’
> > > 4508 |
> > >  +++ |+#include <initializer_list>
> > > 4509 | static void
> > > ......
> > > 4966 |     for (auto op : {BIT_IOR_EXPR, TRUTH_OR_EXPR})
> > >      |                                                ^
> > > ../../gcc/analyzer/region-model.cc:4978:49: error: deducing from brace-enclosed initializer list requires ‘#include <initializer_list>’
> > > 4978 |     for (auto op : {BIT_AND_EXPR, TRUTH_AND_EXPR})
> > >      |                                                 ^
> > >
> > > I think we have 2 options, one is do what you wrote above,
> > > INCLUDE_INITIALIZER_LIST defined before system.h to get #include <initializer_list>.
> > > The other option is just to include that unconditionally, it is a very small
> > > header.  For libstdc++ it will make no difference as it is included anyway
> > > and the header is really small there, libc++ includes <cstddef> which isn't
> > > normally included and system.h includes <stddef.h> instead.
> >
> > I’d say unconditionally would be OK. I suppose the chance that any host
> > C++ is good enough to build GCC as-is but fails to provide
> > <initializer_list> is zero?
> >
> 
> Yes, definitely.
> 
> > I’d be OK to do this change without a new RC even.

I've bootstrapped/regtested this on 12 branch on x86_64-linux and
i686-linux, committed to both.

2022-05-02  Jakub Jelinek  <jakub@redhat.com>

	* system.h: Include initializer_list.

--- gcc/system.h.jj	2022-04-28 15:56:06.786792094 +0200
+++ gcc/system.h	2022-05-01 20:23:04.373273340 +0200
@@ -239,6 +239,7 @@ extern int errno;
 # include <functional>
 #endif
 # include <cstring>
+# include <initializer_list>
 # include <new>
 # include <utility>
 # include <type_traits>


	Jakub


           reply	other threads:[~2022-05-02  5:12 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CAH6eHdTTADarpQmtgq+fwU_UhUZCxzvgU+4GHT0OctmZ_xvTpA@mail.gmail.com>]

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=Ym9oGr8DDtPtTzCA@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=idsandoe@googlemail.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=rguenther@suse.de \
    /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).