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

Cameron McInally cameron.mcinally at nyu.edu
Tue Jan 7 07:52:20 PST 2014


Hey guys,

When compiling LLVM with GCC 4.6.3, the following warning appears when
the -Wuninitialized option is specified:

> llvm/lib/IR/DataLayout.cpp:200:17: warning: 'Result' may be used uninitialized in this function [-Wuninitialized]

Attached is a small patch to initialize Result to 0.

Tx,
Cameron
-------------- next part --------------
Index: lib/IR/DataLayout.cpp
===================================================================
--- lib/IR/DataLayout.cpp	(revision 198693)
+++ lib/IR/DataLayout.cpp	(working copy)
@@ -205,9 +205,9 @@
   return Split;
 }
 
-/// Get an unsinged integer, including error checks.
+/// Get an unsigned integer, including error checks.
 static unsigned getInt(StringRef R) {
-  unsigned Result;
+  unsigned Result = 0;
   bool error = R.getAsInteger(10, Result); (void)error;
   assert(!error && "not a number, or does not fit in an unsigned int");
   return Result;


More information about the llvm-commits mailing list