Meeting 11 October 2018

JetBrains C++ team at CppCon 2018: trip report

Post by Anastasia Kazakova and Phil Nash

Deterministic Disappointment, by Niall Douglas

Let’s add exceptions to C (and Rust/Go/Python etc.)!

  • If a C function is marked with fails(E) its calling convention changes to return union of return type T and error type E.
  • Discriminant is lightweight and architecture-specific (for example, CPU carry flag)
  • Fails-functions must be explicitly called with catch(...) or try(...)
  • fails_errno is a boilerplate expansion and solves the global errno problem

C++

  • Functions can be marked with:

    • throws
    • throws(E)
    • fails(E)
    • noexcept
    • nothing
  • One possible implementation of P0709

  • Solves a few long-standing problems in C and POSIX

  • Enables C code to call C++ code without exception translation wrappers (also Rust, Go, Python etc.)

  • C++ can send/get exceptions to/from C

IT Hare posts on std::error exceptions

  • 1: The Good
    • “While existing C++ exceptions DO have (about)-zero runtime CPU cost when the exception is not fired, it comes at the cost of the path-when-the-exception-IS-fired being huge, and worse – being next-to-impossible to predict in advance.”
    • “With existing exception model, we cannot see which functions are allowed to throw. This leads us to the situation where we need either to (a) think that everything out there can throw (leading to very inefficient use of our brains to make everything out there exception-safe), or (b) forget about exception safety entirely (which actually happens way too often in real-world projects).”
    • “No single error handling method is good enough for ALL the projects – which in turn leads to creation of C++ dialects, with some of the projects using exceptions, and some others using error codes.”
  • 2: The Discussion
  • 3: Unchecked exceptions for C++
    • “There EXIST real-world cases when failing hard is NOT a good option” (Ariane 5)
    • “Fail-Fast-AND-Soft”
    • “Unchecked exceptions MAY be thrown out of nothrow functions without causing trouble” (Hmmm…)
    • ““unchecked” std::errors are treated as “something which should never ever happen, but in practice MAY occur as a result of potentially-recoverable bug””

Concepts TS vs. C++20 Concepts

Reddit

Why is the short-form of concept constraints isn’t included in C++20?

Exploring C++ types with puts(__PRETTY_FUNCTION__)

1template<class T>
2void f() {
3    puts(__PRETTY_FUNCTION__); // __FUNCSIG__ in MSVC
4}
5
6#define EXPLORE(expr) \
7    printf("decltype(" #expr ") is... "); \
8    f<decltype(expr)>();

Mutexes are passé

Reboot Your Dreamliner Every 248 Days To Avoid Integer Overflow

This condition is caused by a software counter internal to the Generator Control Units (GCUs) that will overflow after 248 days of continuous power. We are issuing this to prevent loss of all AC electrical power, which could result in loss of control of the airplane.

Twitter