public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC 13.1 compile error when using CXXFLAGS=-std=c++20
@ 2023-04-27  9:09 Helmut Zeisel
  2023-04-27  9:22 ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Helmut Zeisel @ 2023-04-27  9:09 UTC (permalink / raw)
  To: gcc

I compiled GCC 13.1.0 with GCC 12 and had the environment variable CXXFLAGS set to -std=c++20
This gives the error (both linux and cygin)

gcc-13.1.0/libstdc++-v3/src/c++98/bitmap_allocator.cc:51:23: error: ISO C++17 does not allow dynamic exception specifications
   51 |   _M_get(size_t __sz) throw(std::bad_alloc)

After

   unset CXXFLAGS

compilation works

Helmut

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

* Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
  2023-04-27  9:09 GCC 13.1 compile error when using CXXFLAGS=-std=c++20 Helmut Zeisel
@ 2023-04-27  9:22 ` Jakub Jelinek
  2023-04-27  9:35   ` Aw: " Helmut Zeisel
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2023-04-27  9:22 UTC (permalink / raw)
  To: Helmut Zeisel; +Cc: gcc

On Thu, Apr 27, 2023 at 11:09:19AM +0200, Helmut Zeisel via Gcc wrote:
> I compiled GCC 13.1.0 with GCC 12 and had the environment variable CXXFLAGS set to -std=c++20
> This gives the error (both linux and cygin)
> 
> gcc-13.1.0/libstdc++-v3/src/c++98/bitmap_allocator.cc:51:23: error: ISO C++17 does not allow dynamic exception specifications
>    51 |   _M_get(size_t __sz) throw(std::bad_alloc)
> 
> After
> 
>    unset CXXFLAGS
> 
> compilation works

Don't do it.  libstdc++ carefully decides which parts of it should be
compiled by which C++ standard version.  By forcing it to use
something it wasn't designed to work with you are breaking its assumptions.
Obviously  c++98 code can use C++98 features...

	Jakub


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

* Aw: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
  2023-04-27  9:22 ` Jakub Jelinek
@ 2023-04-27  9:35   ` Helmut Zeisel
  2023-04-27  9:40     ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Helmut Zeisel @ 2023-04-27  9:35 UTC (permalink / raw)
  To: jakub, gcc

>Von: "Jakub Jelinek" <jakub@redhat.com>
>An: "Helmut Zeisel" <HZ2012@gmx.at>
>Cc: gcc@gcc.gnu.org
>Betreff: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
>On Thu, Apr 27, 2023 at 11:09:19AM +0200, Helmut Zeisel via Gcc wrote:
>> I compiled GCC 13.1.0 with GCC 12 and had the environment variable CXXFLAGS set to -std=c++20
>> This gives the error (both linux and cygin)
>>
>> gcc-13.1.0/libstdc++-v3/src/c++98/bitmap_allocator.cc:51:23: error: ISO C++17 does not allow dynamic exception specifications
>> 51 | _M_get(size_t __sz) throw(std::bad_alloc)
>>
>> After
>>
>> unset CXXFLAGS
>>
>> compilation works

>Don't do it. 

Dont do *what*?
export CXXFLAGS=... ?
unset CXXFLAGS ?
Compile GCC 13 with GCC 12?

Helmut

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

* Re: Aw: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
  2023-04-27  9:35   ` Aw: " Helmut Zeisel
@ 2023-04-27  9:40     ` Jakub Jelinek
  2023-05-08  8:38       ` NightStrike
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2023-04-27  9:40 UTC (permalink / raw)
  To: Helmut Zeisel; +Cc: gcc

On Thu, Apr 27, 2023 at 11:35:23AM +0200, Helmut Zeisel wrote:
> >Von: "Jakub Jelinek" <jakub@redhat.com>
> >An: "Helmut Zeisel" <HZ2012@gmx.at>
> >Cc: gcc@gcc.gnu.org
> >Betreff: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
> >On Thu, Apr 27, 2023 at 11:09:19AM +0200, Helmut Zeisel via Gcc wrote:
> >> I compiled GCC 13.1.0 with GCC 12 and had the environment variable CXXFLAGS set to -std=c++20
> >> This gives the error (both linux and cygin)
> >>
> >> gcc-13.1.0/libstdc++-v3/src/c++98/bitmap_allocator.cc:51:23: error: ISO C++17 does not allow dynamic exception specifications
> >> 51 | _M_get(size_t __sz) throw(std::bad_alloc)
> >>
> >> After
> >>
> >> unset CXXFLAGS
> >>
> >> compilation works
> 
> >Don't do it. 
> 
> Dont do *what*?
> export CXXFLAGS=... ?

Include explicit -std= settings in such exported variables, especially when
building GCC.  Packages should decide themselves in which language version
they are written in, or if they are written in common subset, they should
just defer to the compiler default.
Note, doing that would break building even much older GCC versions.

> unset CXXFLAGS ?
> Compile GCC 13 with GCC 12?

	Jakub


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

* Re: Aw: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
  2023-04-27  9:40     ` Jakub Jelinek
@ 2023-05-08  8:38       ` NightStrike
  2023-05-08  8:51         ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: NightStrike @ 2023-05-08  8:38 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Helmut Zeisel, gcc

On Thu, Apr 27, 2023 at 5:41 AM Jakub Jelinek via Gcc <gcc@gcc.gnu.org> wrote:
>
> On Thu, Apr 27, 2023 at 11:35:23AM +0200, Helmut Zeisel wrote:
> > >Von: "Jakub Jelinek" <jakub@redhat.com>
> > >An: "Helmut Zeisel" <HZ2012@gmx.at>
> > >Cc: gcc@gcc.gnu.org
> > >Betreff: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
> > >On Thu, Apr 27, 2023 at 11:09:19AM +0200, Helmut Zeisel via Gcc wrote:
> > >> I compiled GCC 13.1.0 with GCC 12 and had the environment variable CXXFLAGS set to -std=c++20
> > >> This gives the error (both linux and cygin)
> > >>
> > >> gcc-13.1.0/libstdc++-v3/src/c++98/bitmap_allocator.cc:51:23: error: ISO C++17 does not allow dynamic exception specifications
> > >> 51 | _M_get(size_t __sz) throw(std::bad_alloc)
> > >>
> > >> After
> > >>
> > >> unset CXXFLAGS
> > >>
> > >> compilation works
> >
> > >Don't do it.
> >
> > Dont do *what*?
> > export CXXFLAGS=... ?
>
> Include explicit -std= settings in such exported variables, especially when
> building GCC.  Packages should decide themselves in which language version
> they are written in, or if they are written in common subset, they should
> just defer to the compiler default.
> Note, doing that would break building even much older GCC versions.

Maybe configure should catch that?

diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 0dd550a4b4b..f0d998aad94 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -86,6 +86,9 @@ AH_TEMPLATE(VERSION, [Version number of package])
 # -fno-builtin must be present here so that a non-conflicting form of
 # std::exit can be guessed by AC_PROG_CXX, and used in later tests.

+AS_CASE(["$CXXFLAGS"],
+  [*-std=*], [AC_MSG_ERROR([don't do that])])
+
 save_CXXFLAGS="$CXXFLAGS"
 CXXFLAGS="$CXXFLAGS -fno-builtin"
 AC_PROG_CC

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

* Re: Aw: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
  2023-05-08  8:38       ` NightStrike
@ 2023-05-08  8:51         ` Jonathan Wakely
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2023-05-08  8:51 UTC (permalink / raw)
  To: NightStrike; +Cc: Jakub Jelinek, Helmut Zeisel, gcc

[-- Attachment #1: Type: text/plain, Size: 2269 bytes --]

On Mon, 8 May 2023, 09:38 NightStrike via Gcc, <gcc@gcc.gnu.org> wrote:

> On Thu, Apr 27, 2023 at 5:41 AM Jakub Jelinek via Gcc <gcc@gcc.gnu.org>
> wrote:
> >
> > On Thu, Apr 27, 2023 at 11:35:23AM +0200, Helmut Zeisel wrote:
> > > >Von: "Jakub Jelinek" <jakub@redhat.com>
> > > >An: "Helmut Zeisel" <HZ2012@gmx.at>
> > > >Cc: gcc@gcc.gnu.org
> > > >Betreff: Re: GCC 13.1 compile error when using CXXFLAGS=-std=c++20
> > > >On Thu, Apr 27, 2023 at 11:09:19AM +0200, Helmut Zeisel via Gcc wrote:
> > > >> I compiled GCC 13.1.0 with GCC 12 and had the environment variable
> CXXFLAGS set to -std=c++20
> > > >> This gives the error (both linux and cygin)
> > > >>
> > > >> gcc-13.1.0/libstdc++-v3/src/c++98/bitmap_allocator.cc:51:23: error:
> ISO C++17 does not allow dynamic exception specifications
> > > >> 51 | _M_get(size_t __sz) throw(std::bad_alloc)
> > > >>
> > > >> After
> > > >>
> > > >> unset CXXFLAGS
> > > >>
> > > >> compilation works
> > >
> > > >Don't do it.
> > >
> > > Dont do *what*?
> > > export CXXFLAGS=... ?
> >
> > Include explicit -std= settings in such exported variables, especially
> when
> > building GCC.  Packages should decide themselves in which language
> version
> > they are written in, or if they are written in common subset, they should
> > just defer to the compiler default.
> > Note, doing that would break building even much older GCC versions.
>
> Maybe configure should catch that?
>
> diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
> index 0dd550a4b4b..f0d998aad94 100644
> --- a/libstdc++-v3/configure.ac
> +++ b/libstdc++-v3/configure.ac
> @@ -86,6 +86,9 @@ AH_TEMPLATE(VERSION, [Version number of package])
>  # -fno-builtin must be present here so that a non-conflicting form of
>  # std::exit can be guessed by AC_PROG_CXX, and used in later tests.
>
> +AS_CASE(["$CXXFLAGS"],
> +  [*-std=*], [AC_MSG_ERROR([don't do that])])
> +
>  save_CXXFLAGS="$CXXFLAGS"
>  CXXFLAGS="$CXXFLAGS -fno-builtin"
>  AC_PROG_CC
>

Seems like a reasonable idea at first glance, somebody could test and
submit a patch.

That pattern will match a hypothetical option like -ffoo-std=bar which is
not a -std option. I think a better pattern would be needed.

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

end of thread, other threads:[~2023-05-08  8:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27  9:09 GCC 13.1 compile error when using CXXFLAGS=-std=c++20 Helmut Zeisel
2023-04-27  9:22 ` Jakub Jelinek
2023-04-27  9:35   ` Aw: " Helmut Zeisel
2023-04-27  9:40     ` Jakub Jelinek
2023-05-08  8:38       ` NightStrike
2023-05-08  8:51         ` Jonathan Wakely

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