3 ms·
There's only one value "Do" will ever have. He might as well set it from the beginning ;)
by jhasse 9y ago
There's only one value "Do" will ever have. He might as well set it from the beginning ;)
- caf 9y agoThe only value it will ever have is NULL (but calling through a NULL function pointer is UB so it can instead call system() :)
- jhasse 9y agoIt's uninitialized, not NULL. edit: I was wrong, see below.
- unwind 9y agoIt's a global static without an initializing expression; it is set to 0 before main() starts. 0 for a function pointer is of course the same as nullptr/NULL.
- anon1385 9y agoC11 6.7.9 (10): If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. If an object that has static or thread storage duration is not initialized explicitly, then: — if it has pointer type, it is initialized to a null pointer;
- deleted 9y ago[deleted]
- sigjuice 9y agoHow is the C11 standard applicable to a C++ program?
- anon1385 9y agoI didn't notice it was C++. In C++14: From 3.6.2: >Variables with static storage duration (3.7.1) or thread storage duration (3.7.2) shall be zero-initialized (8.5) before any other initialization takes place and from 8.5: >To zero-initialize an object or reference of type T means >--if T is a scalar type (3.9), the object is initialized to the value obtained by converting the integer literal 0 (zero) to T and from 3.9: >Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2), std::nullptr_- t, and cv-qualified versions of these types (3.9.3) are collectively called scalar types