[PATCH] D43230: [clangd] Explicitly initialize all primitive fields in Protocol.h

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 10:06:35 PST 2018


ilya-biryukov added a comment.

In https://reviews.llvm.org/D43230#1006104, @ioeric wrote:

> But I think it's safe and probably easier to rely on default values of primitive types like int, bool etc


It's not always safe, as primitive types are sometimes left uninitialized (e.g. when constructed on the stack) and reading an uninitialized value is UB.

> but do we really want to make this a requirement for future changes or even in our coding style?

I think we should, default values are less surprising than UB. Other people may disagree, though. 
@sammccall , @hokein , WDYT? Should we always initialize primitive types in our code?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43230





More information about the cfe-commits mailing list