Skip to content

Commit 43dc35c

Browse files
committed
test_module: Fix noexcept warning
With gcc 13.3.0 an `-Wnoexcept` I warnings like the following: ``` In file included from .../include/c++/13.3.0/bits/char_traits.h:57, from .../include/c++/13.3.0/string_view:40, from .../ChaiScript/include/chaiscript/chaiscript_defines.hpp:23, from .../ChaiScript/include/chaiscript/chaiscript_basic.hpp:10, from .../ChaiScript/src/test_module.cpp:2: .../include/c++/13.3.0/bits/stl_construct.h: In instantiation of ‘constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = Type2; _Args = {Type2}; decltype (::new(void*(0)) _Tp) = Type2*]’: .../include/c++/13.3.0/bits/stl_construct.h:115:21: required from ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = Type2; _Args = {Type2}]’ .../include/c++/13.3.0/bits/alloc_traits.h:661:19: required from ‘static constexpr void std::allocator_traits<std::allocator<void> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Type2; _Args = {Type2}; allocator_type = std::allocator<void>]’ .../include/c++/13.3.0/bits/shared_ptr_base.h:604:39: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {Type2}; _Tp = Type2; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ .../include/c++/13.3.0/bits/shared_ptr_base.h:971:16: required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = Type2; _Alloc = std::allocator<void>; _Args = {Type2}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ .../include/c++/13.3.0/bits/shared_ptr_base.h:1712:14: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {Type2}; _Tp = Type2; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ .../include/c++/13.3.0/bits/shared_ptr.h:464:59: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {Type2}; _Tp = Type2]’ .../include/c++/13.3.0/bits/shared_ptr.h:1009:14: required from ‘std::shared_ptr<std::_NonArray<_Tp> > std::make_shared(_Args&& ...) [with _Tp = Type2; _Args = {Type2}; _NonArray<_Tp> = Type2]’ .../ChaiScript/include/chaiscript/dispatchkit/boxed_value.hpp:121:37: required from ‘static auto chaiscript::Boxed_Value::Object_Data::get(T, bool) [with T = Type2]’ .../ChaiScript/include/chaiscript/dispatchkit/boxed_value.hpp:133:34: required from ‘chaiscript::Boxed_Value::Boxed_Value(T&&, bool) [with T = Type2; <template-parameter-1-2> = void]’ .../ChaiScript/include/chaiscript/dispatchkit/type_conversions.hpp:480:26: required from ‘chaiscript::Type_Conversion chaiscript::type_conversion(const Callable&) [with From = TestBaseType; To = Type2; Callable = create_chaiscript_module_test_module()::<lambda(const TestBaseType&)>; Type_Conversion = std::shared_ptr<detail::Type_Conversion_Base>]’ .../ChaiScript/src/test_module.cpp:194:58: required from here .../include/c++/13.3.0/bits/stl_construct.h:95:14: warning: noexcept-expression evaluates to ‘false’ because of a call to ‘Type2::Type2(Type2&&)’ [-Wnoexcept] 95 | noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../ChaiScript/src/test_module.cpp:60:7: note: but ‘Type2::Type2(Type2&&)’ does not throw; perhaps it should be declared ‘noexcept’ 60 | class Type2 { | ^~~~~ ``` Fix this by introducing `noexcept` like proposed in the warning.
1 parent 681104b commit 43dc35c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/test_module.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55

66
class TestBaseType {
77
public:
8-
TestBaseType()
8+
TestBaseType() noexcept
99
: val(10)
1010
, const_val(15)
1111
, mdarray{} {
1212
}
13-
TestBaseType(int)
13+
TestBaseType(int) noexcept
1414
: val(10)
1515
, const_val(15)
1616
, mdarray{} {
1717
}
18-
TestBaseType(int *)
18+
TestBaseType(int *) noexcept
1919
: val(10)
2020
, const_val(15)
2121
, mdarray{} {
2222
}
2323

24-
TestBaseType(const TestBaseType &other)
24+
TestBaseType(const TestBaseType &other) noexcept
2525
: val(other.val)
2626
, const_val(other.const_val)
2727
, const_val_ptr(&const_val)
2828
, func_member(other.func_member) {
2929
}
3030

31-
TestBaseType(TestBaseType &&other)
31+
TestBaseType(TestBaseType &&other) noexcept
3232
: val(other.val)
3333
, const_val(other.const_val)
3434
, const_val_ptr(&const_val)
@@ -59,7 +59,7 @@ class TestBaseType {
5959

6060
class Type2 {
6161
public:
62-
Type2(TestBaseType t_bt)
62+
Type2(TestBaseType t_bt) noexcept
6363
: m_bt(std::move(t_bt))
6464
, m_str("Hello World") {
6565
}

0 commit comments

Comments
 (0)