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

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 02:19:31 PST 2019


peter.smith added a comment.

One thing that might work better than potentially random problems if the containers aren't cleared, is some kind of assert only, or self-diagnosis mode that could give an assert or error message that a data-structure hadn't been cleared. For example assert(inputSections.empty()); assert(In.bss == nullptr);.  With asserts checking I think we could get away with a small set of tests to run twice with some --self-diagnostic-option to check the majority of the cases.

I agree with blackhole12 that this doesn't solve the problem for new global variables, it only mitigates refactoring of existing ones although it does provide a strong hint as to what should be done. A RAII container for the existing containers could help, although it again suffers from the problem that we'd need to remember to use one for new globals. I think it would need to be combined with some kind of testing.


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