From 4428e8e8b3056239817407af04f921d96a24dcdd Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 12 Sep 2020 14:29:19 +0200 Subject: [PATCH] glr2.cc: fix GCC10 warning For instance on test 433: "glr2.cc api.value.type={double}" tests/types.at:138: $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o test test.cc $LIBS stderr: In file included from /opt/local/include/gcc10/c++/bits/stl_tempbuf.h:60, from /opt/local/include/gcc10/c++/bits/stl_algo.h:62, from /opt/local/include/gcc10/c++/algorithm:62, from test.cc:82: /opt/local/include/gcc10/c++/bits/stl_construct.h: In instantiation of 'constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = glr_stack_item; _Args = {glr_stack_item}; decltype (::new(void*(0)) _Tp) = glr_stack_item*]': /opt/local/include/gcc10/c++/bits/alloc_traits.h:514:21: required from 'static constexpr void std::allocator_traits >::construct(std::allocator_traits >::allocator_type&, _Up*, _Args&& ...) [with _Up = glr_stack_item; _Args = {glr_stack_item}; _Tp = glr_stack_item; std::allocator_traits >::allocator_type = std::allocator]' /opt/local/include/gcc10/c++/bits/vector.tcc:115:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {glr_stack_item}; _Tp = glr_stack_item; _Alloc = std::allocator; std::vector<_Tp, _Alloc>::reference = glr_stack_item&]' /opt/local/include/gcc10/c++/bits/stl_vector.h:1204:21: required from 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = glr_stack_item; _Alloc = std::allocator; std::vector<_Tp, _Alloc>::value_type = glr_stack_item]' test.cc:1949:48: required from here /opt/local/include/gcc10/c++/bits/stl_construct.h:95:14: error: noexcept-expression evaluates to 'false' because of a call to 'glr_stack_item::glr_stack_item(const glr_stack_item&)' [-Werror=noexcept] 95 | noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.cc:1436:3: note: but 'glr_stack_item::glr_stack_item(const glr_stack_item&)' does not throw; perhaps it should be declared 'noexcept' 1436 | glr_stack_item(const glr_stack_item& other) | ^~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors stdout: tests/types.at:138: exit code was 1, expected 0 433. types.at:138: 433. glr2.cc api.value.type={double} (types.at:138): FAILED (types.at:138) * data/skeletons/glr2.cc (glr_stack_item): Use YY_NOEXCEPT/YY_NOTHROW. --- data/skeletons/glr2.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc index ac9ce051..514dfa4b 100644 --- a/data/skeletons/glr2.cc +++ b/data/skeletons/glr2.cc @@ -1227,7 +1227,7 @@ class glr_stack_item { } } - glr_stack_item(const glr_stack_item& other) + glr_stack_item(const glr_stack_item& other) YY_NOEXCEPT YY_NOTHROW : isState_(other.isState_) { std::memcpy(raw_, other.raw_, union_size); }