Re: Problems testing Bison with GCC 12.1

Akim Demaille <[email protected]> Mon, 1 Aug 2022 08:08:07 +0200
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>

> Le 1 ao=C3=BBt 2022 =C3=A0 07:18, Akim Demaille =
<[email protected]> a =C3=A9crit :
>=20
>=20
>=20
>> Le 1 ao=C3=BBt 2022 =C3=A0 07:02, Akim Demaille =
<[email protected]> a =C3=A9crit :
>>=20
>>> Many C++ tests (400-25, 440-53, 664-5, 667-76, 679-80, 682-3, 685-9, =
692) fail with diagnostics like "noexcept-expression evaluates to =
'false' because of a call to =
'yy::parser::stack_symbol_type::stack_symbol_type()' =
[-Werror=3Dnoexcept]".
>>=20
>> I'll have a look at that.
>=20
> I'm installing this:
>=20
> commit 722070124e991ee93ec3ffbde631b5f3713cd9f0
> Author: Akim Demaille <[email protected]>
> Date:   Mon Aug 1 07:08:52 2022 +0200
>=20
>    lalr1.cc: declare stack_symbol_type as noexcept

I'm adding that.

commit b7bdf78c1836dd103fed56105676ef8de3f33c45
Author: Akim Demaille <[email protected]>
Date:   Mon Aug 1 08:02:20 2022 +0200

    glr2.cc: fix -Wnoexcept issues
   =20
    440-453 and 685 failed with GCC 12.1:
   =20
    ```
    test.cc:1814:21:   required from here
    /opt/local/include/gcc12/c++/bits/stl_construct.h:95:14: error: =
noexcept-expression evaluates to 'false' because of a call to =
'{anonymous}::glr_stack_item::glr_stack_item(bool)' [-Werror=3Dnoexcept]
       95 |     noexcept(noexcept(::new((void*)0) =
_Tp(std::declval<_Args>()...)))
          |              =
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    test.cc:1486:5: note: but =
'{anonymous}::glr_stack_item::glr_stack_item(bool)' does not throw; =
perhaps it should be declared 'noexcept'
     1486 |     glr_stack_item (bool state =3D true)
          |     ^~~~~~~~~~~~~~
    ```
   =20
    Reported by Paul Eggert.
    <https://lists.gnu.org/r/bison-patches/2022-07/msg00008.html>
   =20
    * data/skeletons/glr2.cc (glr_state, glr_stack_item): Declare the
    default ctors noexcept.

diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 604de731..970ccfdf 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -818,7 +818,7 @@ namespace ]b4_namespace_ref[
   class ]b4_parser_class[::glr_state
   {
   public:
-    glr_state ()
+    glr_state () YY_NOEXCEPT
       : yyresolved (false)
       , yylrState (0)
       , yyposn (0)
@@ -1410,7 +1410,7 @@ namespace
   class glr_stack_item
   {
   public:
-    glr_stack_item (bool state =3D true)
+    glr_stack_item (bool state =3D true) YY_NOEXCEPT
       : is_state_ (state)]b4_parse_assert_if([[
       , magic_ (MAGIC)]])[
     {