Jun. 16th, 2010

C++ FQA

Jun. 16th, 2010 10:45 am
tinedel: (Default)
FQA: Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
tinedel: (Default)
What's the "static initialization order fiasco"?

FAQ: A subtle, frequently misunderstood source of errors, which are hard to catch because they occur before main is called. The errors can happen when the constructor of a global object defined in x.cpp accesses (directly or indirectly) a global object defined in y.cpp. The order of initialization of these objects is undefined, so you'll see the problem in 50% of the cases (an error may be triggered by a rebuild). "It's that simple".

FQA: And it's that stupid. Just look at this:

* C++ doesn't define the order of initialization of global objects.
* C++ lets you write code that depends on the order of initialization of global objects.
* C++ doesn't have a mechanism to automatically detect these errors, neither at compile time nor at run time.
* C++ doesn't make the slightest effort to help you debug the problem (for example, go figure in which actual order the objects were initialized).

Profile

tinedel: (Default)
Ivan

April 2017

S M T W T F S
      1
2345678
910 1112131415
16171819202122
23242526272829
30      

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 23rd, 2025 08:44 am
Powered by Dreamwidth Studios