From 74a76a96f498abc68ac9d6fc5fb7d5b06af8d418 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 28 May 2020 10:09:46 -0400 Subject: [PATCH] On error, one should exit and not abort. Aborting bypasses destructors and dumps core. It is harsh and potentially dangerous. We want a nice error message, even when exceptions and disabled, not a "dumping core" message. --- include/cxxopts.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 3dd5f52..e47cb81 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -480,11 +480,10 @@ namespace cxxopts throw T{text}; #else // Otherwise manually instantiate the exception, print what() to stderr, - // and abort + // and exit T exception{text}; std::cerr << exception.what() << std::endl; - std::cerr << "Aborting (exceptions disabled)..." << std::endl; - std::abort(); + std::exit(EXIT_FAILURE); #endif }