From 177eb0fab3ce51f872a7f792136a99b19d61af5e Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 13 Sep 2014 04:55:57 +0200 Subject: [PATCH] DOC: notes regarding the current level of C++11 support --- doc/technical/code/c++11.txt | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/doc/technical/code/c++11.txt b/doc/technical/code/c++11.txt index 0aa8cd613..c45017c2c 100644 --- a/doc/technical/code/c++11.txt +++ b/doc/technical/code/c++11.txt @@ -93,3 +93,47 @@ ASCII 'A' = 65 defined: 1 undefd; 0 bool-convertible: 0 can build bool: 1 bool f ---- + +Known bugs and tricky situations +-------------------------------- +Summer 2014:: + the basic switch to C++11 compilation is done by now, but we have yet to deal with + some ``ripple effects''. +September 2014:: + and those problems turn out to be somewhat insidious: our _reference system_ is still Debian/stable, + which means we're using *GCC-4.7* and *CLang 3.0*. While these compilers both provide a roughly complete + C++11 support, a lot of fine points were discovered in the follow-up versions of the compilers and standard + library -- current versions being GCC-3.9 and CLang 3.4 + + * GCC-4.7 was too liberal and sloppy at some points, where 4.8 rightfully spotted conceptual problems + * CLang 3.0 turns out to be really immature and even segfaults on some combinations of new language features + * Thus we've got some kind of a _situation:_ We need to hold back further modernisation and just hope that + GCC-4.7 doesn't blow up; CLang is even worse, Version 3.0 us unusable after our C++11 transition. + We're forced to check our builds on Debian/testing, and we should consider to _raise our general + requirement level_ soon. + +Perfect forwarding +~~~~~~~~~~~~~~~~~~ +The ``perfect forwarding'' technique in conjunction with variadic templates promises to obsolete a lot of +template trickery when it comes to implementing custom containers, allocators or similar kinds of managing wrappers. +Unfortunately, we ran into nasty problems with both GCC-4.7 and CLang 3.0 here, when chaining several forwarding calls. + +- the new _reference collapsing rules_ seem to be unreliably still. Note that even the standard library uses an + overload to implement `std::forward`, while in theory, a single definition should work for every case. +- in one case, the executable generated by GCC passed a reference to an temporary, where it should have + passed a rvalue reference (i.e. it should have _moved_ the temporary, instead of referring to the + location on stack) +- CLang is unable to pass a plain-flat rvalue through a chain of templated functions with rvalue references. + We get the inspiring error message ``binding of reference to type `std::basic_string` to a value of + type `std::basic_string` drops qualifiers'' + +Thus -- as of 9/2014 -- the _rules of the game_ are as folows + +- it is OK to take arguments by rvalue reference, when the type is explicit +- it is OK to use std::forward _once_ to pass-trough a templated argument +- but the _time is not yet ready_ to get rid of intermediary copies +- we still prefer returning by value (eligible for RVO) and copy-initialisation +- we refrain from switching our metaprogramming code from Loki-Typelists and hand-written specialisations + to variadic templates and `std::tuple` + +