Project

General

Profile

Actions

Bug #5638

closed

throw from destructors will always call terminate in C++11 or newer (destructors default to noexcept)

Added by Keith Bennett over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/31/2017
Due date:
% Done:

0%

Estimated time:

Description

When building with GCC 6 (which defaults standard to -std=c+14 instead of -std=c+98), compiler emits warnings:

In file included from /home/keithb/Downloads/wt/wt-3.3.6/src/Wt/Dbo/Impl:13:0,
                 from /home/keithb/Downloads/wt/wt-3.3.6/src/Wt/Dbo/Dbo:11,
                 from /home/keithb/Downloads/wt/wt-3.3.6/test/dbo/DboTest3.C:9:
/home/keithb/Downloads/wt/wt-3.3.6/src/Wt/Dbo/ptr_impl.h: In instantiation of ‘Wt::Dbo::MetaDbo<C>::~MetaDbo() [with C = FuncTest]’:
/home/keithb/Downloads/wt/wt-3.3.6/test/dbo/DboTest3.C:172:1:   required from here
/home/keithb/Downloads/wt/wt-3.3.6/src/Wt/Dbo/ptr_impl.h:52:47: warning: throw will always call terminate() [-Wterminate]
     throw std::logic_error("Dbo: refCount > 0");
                                               ^
/home/keithb/Downloads/wt/wt-3.3.6/src/Wt/Dbo/ptr_impl.h:52:47: note: in C++11 destructors default to noexcept

There are a few tens of these warnings. The warnings are triggered with the code in ./test/ uses code the Dbo objects in ./src/Wt/Dbo/ptr_impl.h. It appears to be limited to this single line. Since the warning is from not-test code, termination would occur in any client application which destroys this object. A simple workaround might be to declare noexcept(false), though this doesn't solve the problem that code is throwing from a destructor (which is generally bad behavior anyway).

Reproduction steps:

  • Download Wt tarball, extract, cd into it
  • mkdir build && cd build
  • cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/INSTALLED -DCMAKE_BUILD_TYPE="Release" -DBOOST_ROOT=/usr/local/boost-1.62.0-gcc6.2 ../ && make -j$(nproc) && make test

... wait some time, this thing takes a while to build ...

  • Notice compiler warnings being emitted.

Briefly searched Redmine for related issues, found none: http://redmine.webtoolkit.eu/projects/wt/search?utf8=%E2%9C%93&issues=1&q=always+call+terminate

This is with:

$ cat /etc/lsb-release && cmake --version && gcc --version && grep "#define BOOST_VERSION " /usr/local/boost-1.62.0-gcc6.2/include/boost/version.hpp
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
cmake version 3.7.20161215-g59461c

CMake suite maintained and supported by Kitware (kitware.com/cmake).
gcc (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#define BOOST_VERSION 106200
Actions #1

Updated by Roel Standaert over 8 years ago

  • Status changed from New to Closed

We'd already noticed and fixed that, and this problem should not be there anymore with Wt 3.3.7.

Actions

Also available in: Atom PDF