Skip to content

throw in destructors #14

@dirk-zimoch

Description

@dirk-zimoch

The destructors ~casAsyncReadIO, ~casAsyncWriteIO, ~casAsyncPVExistIO and ~casAsyncPVAttachIO throw exceptions. This is no longer allowed from C++11 on and the compilers issue warnings:

gcc:

../../../../src/pcas/generic/casAsyncPVExistIO.cc: In destructor ‘virtual casAsyncPVExistIO::~casAsyncPVExistIO()’:
../../../../src/pcas/generic/casAsyncPVExistIO.cc:35:9: warning: ‘throw’ will always call ‘terminate’ [-Wterminate]
   35 |         throw std::logic_error (
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
   36 |             "the server library *must* initiate asynchronous IO destroy" );
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../src/pcas/generic/casAsyncPVExistIO.cc:35:9: note: in C++11 destructors default to ‘noexcept’

clang:

../../../../src/pcas/generic/casAsyncPVExistIO.cc:35:9: warning: '~casAsyncPVExistIO' has a non-throwing exception specification but can still throw [-Wexceptions]
   35 |         throw std::logic_error (
      |         ^
../../../../src/pcas/generic/casAsyncPVExistIO.cc:32:20: note: destructor has a implicit non-throwing exception specification
   32 | casAsyncPVExistIO::~casAsyncPVExistIO ()
      |                    ^

Windows cl:

src\pcas\generic\casAsyncPVExistIO.cc(35): warning C4297: 'casAsyncPVExistIO::~casAsyncPVExistIO': function assumed not to throw an exception but does
src\pcas\generic\casAsyncPVExistIO.cc(35): note: destructor or deallocator has a (possibly implicit) non-throwing exception specification

Not sure how best address this. Ignoring it? Simply adding noexcept(false) "everywhere"? Rewriting the destructors not to throw? But how?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions