This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

<future> vs -fno-exceptions


Although I'm updating <future> I'm not implementing the idea below,
I'm sending this mail just so the info is archived.


With -fno-exceptions std::copy_exception() does nothing, which seems
reasonable (although maybe it should return an empty exception_ptr)

std::promise::set_exception() uses std::copy_exception(), so with
-fno-exceptions that will store an empty exception_ptr. When you call
get() on an associated future the future will see the exception_ptr is
empty and then try to return a non-existent value, invoking undefined
behaviour.

It might be nice if -fno-exceptions caused futures to use a boolean
flag instead of an exception_ptr, so that calling
promise::set_exception() sets the flag and future::get() aborts if the
flag is set. That would mean an error could still be stored for later,
and would only abort if someone checks the result.  That would make
promises and futures usable even with exceptions disabled.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]