[llvm] r199147 - Fix uninitialized warning in llvm/lib/IR/DataLayout.cpp.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Jan 13 20:35:34 PST 2014


> Was this a Clang -Wuninitialized? I owuldn't think so.
>
> If GCC was warning here and Clang wasn't, we would generally prefer /not/ to
> initialize this variable (and possibly suppress the GCC warning).

Correct. Since this could be reached with a broken datalayout, we
fixed the issue by not initializing Result but checking error on
release builds too.

> The reason for this is that if there is no use-of-uninitialized (which there
> isn't, with your fix, by the looks of it) at runtime, the code is correct
> and runtime tools like Valgrind and MSan can detect bugs that may be
> introduced. If we initialize the variable to suppress the warning, the
> runtime tools will never tell us about our bugs.

Exactly.

Cheers,
Rafael



More information about the llvm-commits mailing list