<br><br><div>On Mon Jan 13 2014 at 2:12:08 PM, Cameron McInally <<a href="mailto:cameron.mcinally@nyu.edu">cameron.mcinally@nyu.edu</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: mcinally<br>
Date: Mon Jan 13 16:04:55 2014<br>
New Revision: 199147<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=199147&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=199147&view=rev</a><br>
Log:<br>
Fix uninitialized warning in llvm/lib/IR/DataLayout.cpp.<br>
<br>
Added:<br>
    llvm/trunk/test/Assembler/<u></u>getInt.ll<br>
Modified:<br>
    llvm/trunk/lib/IR/DataLayout.<u></u>cpp<br>
<br>
Modified: llvm/trunk/lib/IR/DataLayout.<u></u>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DataLayout.cpp?rev=199147&r1=199146&r2=199147&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/IR/<u></u>DataLayout.cpp?rev=199147&r1=<u></u>199146&r2=199147&view=diff</a><br>

==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/IR/DataLayout.<u></u>cpp (original)<br>
+++ llvm/trunk/lib/IR/DataLayout.<u></u>cpp Mon Jan 13 16:04:55 2014<br>
@@ -207,9 +207,10 @@ static std::pair<StringRef, StringRef> s<br>
<br>
 /// Get an unsigned integer, including error checks.<br>
 static unsigned getInt(StringRef R) {<br>
-  unsigned Result = 0;<br></blockquote><div><br></div><div>Was this a Clang -Wuninitialized? I owuldn't think so. <br><br>If GCC was warning here and Clang wasn't, we would generally prefer /not/ to initialize this variable (and possibly suppress the GCC warning).<br>
<br>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.<br>
<br>- David</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  unsigned Result;<br>
   bool error = R.getAsInteger(10, Result); (void)error;<br>
-  assert(!error && "not a number, or does not fit in an unsigned int");<br>
+  if (error)<br>
+    report_fatal_error("not a number, or does not fit in an unsigned int");<br>
   return Result;<br>
 }<br>
<br>
<br>
Added: llvm/trunk/test/Assembler/<u></u>getInt.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/getInt.ll?rev=199147&view=auto" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/test/<u></u>Assembler/getInt.ll?rev=<u></u>199147&view=auto</a><br>

==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/test/Assembler/<u></u>getInt.ll (added)<br>
+++ llvm/trunk/test/Assembler/<u></u>getInt.ll Mon Jan 13 16:04:55 2014<br>
@@ -0,0 +1,4 @@<br>
+; RUN: opt < %s<br>
+; XFAIL: *<br>
+<br>
+target datalayout = "p:4294967296:64:64"<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote>