[llvm] r243996 - Avoid passing nullptr to std::equal.

Yaron Keren yaron.keren at gmail.com
Tue Aug 4 08:57:04 PDT 2015


Author: yrnkrn
Date: Tue Aug  4 10:57:04 2015
New Revision: 243996

URL: http://llvm.org/viewvc/llvm-project?rev=243996&view=rev
Log:
Avoid passing nullptr to std::equal. 
As documented in the LLVM Coding Standards, indeed MSVC incorrectly asserts 
on this in Debug mode. This happens when building clang with Visual C++ and
-triple i686-pc-windows-gnu on these clang regression tests:

 clang/test/CodeGen/2011-03-08-ZeroFieldUnionInitializer.c
 clang/test/CodeGen/empty-union-init.c


Modified:
    llvm/trunk/lib/IR/Type.cpp

Modified: llvm/trunk/lib/IR/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=243996&r1=243995&r2=243996&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Type.cpp (original)
+++ llvm/trunk/lib/IR/Type.cpp Tue Aug  4 10:57:04 2015
@@ -612,7 +612,8 @@ bool StructType::isLayoutIdentical(Struc
       getNumElements() != Other->getNumElements())
     return false;
   
-  return std::equal(element_begin(), element_end(), Other->element_begin());
+  return element_begin() &&
+         std::equal(element_begin(), element_end(), Other->element_begin());
 }
 
 /// getTypeByName - Return the type with the specified name, or null if there





More information about the llvm-commits mailing list