Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / C++ [игнор отключен] [закрыт для гостей] / странное задание из теста / 3 сообщений из 3, страница 1 из 1
20.03.2018, 05:41
    #39617147
polin11
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
странное задание из теста
Вопрос: if a function throws an exception that is not listed in the function exception-specification list and noexcept is not specified, then
1) unexpected() is immediately invoked
2) terminate() is immediately invoked
3) abort() is immediately invoked
4) unhandled() is immediately invoked
5) the exception is passed up the handler chain
По мне ответ должен быть и 1) и затем 2)
unexpected() is called if a function throws an exception that is not listed in an exception specification. Calls unexpected(), which calls terminate()
По мнению автора вопроса, ответ должен быть 1
...
Рейтинг: 0 / 0
20.03.2018, 11:24
    #39617344
YuriyRusinov
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
странное задание из теста
Если в модуле, который вызвает функцию, прописан обработчик exception вида
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
try {
    your_func();
}
catch (...)
{
    // do_smth.
}


то terminate до этого обработчика вызывать нельзя. Поэтому автор прав.
...
Рейтинг: 0 / 0
20.03.2018, 13:01
    #39617458
MasterZiv
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
странное задание из теста
polin11,

http://en.cppreference.com/w/cpp/language/except_spec

cppreferenceIf the function throws an exception of the type not listed in its exception specification, the function std::unexpected is called. The default function calls std::terminate, but it may be replaced by a user-provided function (via std::set_unexpected) which may call std::terminate or throw an exception. If the exception thrown from std::unexpected is accepted by the exception specification, stack unwinding continues as usual. If it isn't, but std::bad_exception is allowed by the exception specification, std::bad_exception is thrown. Otherwise, std::terminate is called.


Ответ (1)

Но это уже устарело.
exception specification depricated.
...
Рейтинг: 0 / 0
Форумы / C++ [игнор отключен] [закрыт для гостей] / странное задание из теста / 3 сообщений из 3, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]