*this

Serge « sans paille » Guelton

(gdb) p me
$1 = {goblin_tinkerer = true, orcish_lumberjack = true,
  monastery_swiftspear = true}

Dad's Joke

C++ is exactly that:

increment C and return the old value

Abandon your ego

Removing RTTI

-fno-rtti

  1. (almost) No more dynamic_cast<...>(...)
  2. No more typeid(...)

But keeps the type information needed for exceptions

Workaround

from libcxx

template <class _Tp>
struct  __unique_typeinfo { static constexpr int __id = 0; };
template <class _Tp> constexpr int __unique_typeinfo<_Tp>::__id;

template <class _Tp>
inline
constexpr const void* __get_fallback_typeid() {
    return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
}

Removing Exception

-fno-exceptions

  1. No more exception throwing / catching
  2. Still register function unwinders

Workaround

from frozen

#if (defined(_MSC_VER) && !defined(_CPPUNWIND)) || \
    (!defined(_MSC_VER) && !defined(__cpp_exceptions))

#include <cstdlib>
#define FROZEN_THROW_OR_ABORT(_) std::abort()

#else

#include <stdexcept>
#define FROZEN_THROW_OR_ABORT(err) throw err

#endif

Removing the standard library runtime

s/g++/gcc as linker. Say goodbye to…

  1. non-header only types / functions
  2. some template functions that are explicitly instanciated
  3. language features that require library support
    • default new / delete
    • in-function static constructors

Placement new are still ok :-)

Workaround

void* operator new(size_t n) noexcept
{
    return malloc(n);
}

void operator delete(void * p) noexcept
{
    free(p);
}

Remove (almost) all the things

-ffreestanding (See also: -mkernel)

A few allowed headers, including:

Exceptions and typeid are still in!

And most surprisingly

What's left when you gave up everything?

A very Cool C language :-)

Three tales

  1. GCC
  2. LLVM
  3. Numpy

GCC

https://gcc.gnu.org/codingconventions.html

> C++ is a complex language, and we strive to use it in a manner that is not surprising

LLVM

https://llvm.org/docs/CodingStandards.html

Numpy

PR#19713 (merged)

> Replace numpy custom generation engine by raw C++

clang-tidy

Concluding words

It's okay to see C++ as a protean language

1