From a639e155a28014a7b5af8198f775dc2a1e368450 Mon Sep 17 00:00:00 2001 From: Yaron Keren Date: Tue, 4 Aug 2015 15:57:04 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243996 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Type.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp index 18c2e8c2b48..2f6dbab7201 100644 --- a/lib/IR/Type.cpp +++ b/lib/IR/Type.cpp @@ -612,7 +612,8 @@ bool StructType::isLayoutIdentical(StructType *Other) const { 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 -- 2.34.1