[PATCH] D70421: Initialize global vectors with invalid members to catch uninitialization errors

Erik McClure via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 00:22:21 PST 2019


blackhole12 added a comment.

I am not particularly convinced that this will fix the problem, as it simply moves the problem around - instead of having to remember to clean up global variables, now programmers have to remember to initialize them with invalid values. This would certainly make it easier to detect errors once you realize there is one, but if someone silently adds a global variable and forgets to initialize it, you're back at square one. The only reliable way to fix the problem is to create an object whose constructor or destructor is automatically called when necessary, which is why I suggested a global container object. Adding anything to the global container object doesn't require the programmer to remember anything, because the destructor will automatically destruct everything inside of it. If this is simply not possible, some sort of baseline test as suggested by MaskRay is likely your only option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70421/new/

https://reviews.llvm.org/D70421





More information about the llvm-commits mailing list