From b8916aa22fe1d2c1163986b834f5bd0543476573 Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 16 Jun 2016 09:16:00 -0700 Subject: Don't global initialize anything to nullptr --- doc/cpp-style-guide.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/cpp-style-guide.md b/doc/cpp-style-guide.md index 9408c4abd6..0138ceb737 100644 --- a/doc/cpp-style-guide.md +++ b/doc/cpp-style-guide.md @@ -53,6 +53,12 @@ default capture). Other C++ functional features such as (../include/grpc++/impl/codegen/config.h). Instead, pointers should be checked for validity using their implicit conversion to `bool`. In other words, use `if (p)` rather than `if (p != nullptr)` +- Do not initialize global/static pointer variables to `nullptr`. Just let + the compiler implicitly initialize them to `nullptr` (which it will + definitely do). The reason is that `nullptr` is an actual object in + our implementation rather than just a constant pointer value, so + static/global constructors will be called in a potentially + undesirable sequence. - Do not use `final` or `override` as these are not supported by some compilers. Instead use `GRPC_FINAL` and `GRPC_OVERRIDE` . These compile down to the traditional C++ forms for compilers that support -- cgit v1.2.3