<div dir="ltr">Should be fixed with r224040.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 11, 2014 at 3:34 AM, Will Wilson <span dir="ltr"><<a href="mailto:will@indefiant.com" target="_blank">will@indefiant.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi David,<div><br></div><div>Looks like r223852 might be responsible for the following failure I just ran into:</div><div><br></div><div><div>Assertion failed: (D && "Cannot get layout of forward declarations!"), function getASTRecordLayout, file clang/lib/AST/RecordLayoutBuilder.cpp, line 2806.</div><div><br></div><div>0 clang 0x0000000102d14bee llvm::sys::PrintStackTrace(__sFILE*) + 46</div><div>1 clang 0x0000000102d15f9b PrintStackTraceSignalHandler(void*) + 27<br></div><div>2 clang 0x0000000102d163e5 SignalHandler(int) + 565<br></div><div>3 libsystem_platform.dylib 0x00007fff8e013f1a _sigtramp + 26<br></div><div>4 clang 0x00000001061d3dff guard variable for isAllowedIDChar(unsigned int, clang::LangOptions const&)::C99AllowedIDChars + 144135<br></div><div>5 clang 0x0000000102d15fcb raise + 27<br></div><div>6 clang 0x0000000102d16082 abort + 18<br></div><div>7 clang 0x0000000102d16061 __assert_rtn + 129<br></div><div>8 clang 0x000000010558eecd clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const + 285<br></div><div>9 clang 0x00000001052345e7 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const + 4951<br></div><div>10 clang 0x00000001052331b5 clang::ASTContext::getTypeInfo(clang::Type const*) const + 165<br></div><div>11 clang 0x00000001052a504c clang::ASTContext::getTypeInfo(clang::QualType) const + 44<br></div><div>12 clang 0x00000001052acfe5 clang::ASTContext::getTypeSize(clang::QualType) const + 37<br></div><div><b>13 clang 0x0000000105519b51 isZeroSized((anonymous namespace)::LValue const&) + 113</b><br></div><div>14 clang 0x00000001054d610e (anonymous namespace)::IntExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*) + 4590<br></div><div>15 clang 0x00000001054d3f08 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::VisitBinNE(clang::BinaryOperator const*) + 40<br></div><div>16 clang 0x00000001054d2240 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*) + 528<br></div><div>17 clang 0x00000001054cc232 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) + 450<br></div><div>18 clang 0x00000001054c81b1 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) + 177<br></div><div>19 clang 0x00000001054c7e1e clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&) const + 190<br></div><div>20 clang 0x0000000104844cf3 clang::Sema::VerifyIntegerConstantExpression(clang::Expr*, llvm::APSInt*, clang::Sema::VerifyICEDiagnoser&, bool) + 931<br></div><div>21 clang 0x00000001048425c8 clang::Sema::VerifyIntegerConstantExpression(clang::Expr*, llvm::APSInt*, unsigned int, bool) + 120<br></div><div>22 clang 0x0000000104737c01 clang::Sema::BuildStaticAssertDeclaration(clang::SourceLocation, clang::Expr*, clang::StringLiteral*, clang::SourceLocation, bool) + 369<br></div><div>23 clang 0x0000000104737a74 clang::Sema::ActOnStaticAssertDeclaration(clang::SourceLocation, clang::Expr*, clang::Expr*, clang::SourceLocation) + 180<br></div><div>24 clang 0x00000001042dcb5c clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) + 1564<br></div><div>25 clang 0x00000001042c0614 clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 852<br></div><div>26 clang 0x000000010435b003 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 2403<br></div><div>27 clang 0x000000010435a655 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 773<br></div><div>28 clang 0x00000001042b1d8c clang::ParseAST(clang::Sema&, bool, bool) + 988<br></div><div>29 clang 0x00000001031db9fa clang::ASTFrontendAction::ExecuteAction() + 522<br></div><div>30 clang 0x00000001037b80d3 clang::CodeGenAction::ExecuteAction() + 3939<br></div><div>31 clang 0x00000001031daf78 clang::FrontendAction::Execute() + 120<br></div><div>32 clang 0x000000010316cbf9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1017<br></div><div>33 clang 0x000000010324c5f1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3201<br></div><div>34 clang 0x0000000101373930 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 2496<br></div><div><br></div></div><div>Repro:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>struct Foo;</div></div><div><div>struct Bar</div></div><div><div>{</div></div><div><div> static const Foo ms_struct;</div></div><div><div>};</div></div><div><div>static_assert(&Bar:: ms_struct != nullptr, "fail");</div></div><div><br></div></blockquote>Will.</div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On 10 December 2014 at 09:32, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Tue Dec 9 17:32:34 2014<br>
New Revision: 223852<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223852&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223852&view=rev</a><br>
Log:<br>
AST: Don't assume two zero sized objects live at different addresses<br>
<br>
Zero sized objects may overlap with each other or any other object.<br>
<br>
This fixes PR21786.<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/ExprConstant.cpp<br>
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/ExprConstant.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=223852&r1=223851&r2=223852&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=223852&r1=223851&r2=223852&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)<br>
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Dec 9 17:32:34 2014<br>
@@ -1422,6 +1422,12 @@ static bool IsWeakLValue(const LValue &V<br>
return Decl && Decl->isWeak();<br>
}<br>
<br>
+static bool isZeroSized(const LValue &Value) {<br>
+ const ValueDecl *Decl = GetLValueBaseDecl(Value);<br>
+ return Decl && isa<VarDecl>(Decl) &&<br>
+ Decl->getASTContext().getTypeSize(Decl->getType()) == 0;<br>
+}<br>
+<br>
static bool EvalPointerValueAsBool(const APValue &Value, bool &Result) {<br>
// A null base expression indicates a null pointer. These are always<br>
// evaluatable, and they are false unless the offset is zero.<br>
@@ -6979,6 +6985,10 @@ bool IntExprEvaluator::VisitBinaryOperat<br>
(RHSValue.Base && RHSValue.Offset.isZero() &&<br>
isOnePastTheEndOfCompleteObject(Info.Ctx, LHSValue)))<br>
return Error(E);<br>
+ // We can't tell whether an object is at the same address as another<br>
+ // zero sized object.<br>
+ if (isZeroSized(LHSValue) || isZeroSized(RHSValue))<br>
+ return Error(E);<br>
// Pointers with different bases cannot represent the same object.<br>
// (Note that clang defaults to -fmerge-all-constants, which can<br>
// lead to inconsistent results for comparisons involving the address<br>
<br>
Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=223852&r1=223851&r2=223852&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=223852&r1=223851&r2=223852&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Tue Dec 9 17:32:34 2014<br>
@@ -1955,3 +1955,9 @@ namespace EmptyClass {<br>
constexpr E2 e2b(e2); // expected-error {{constant expression}} expected-note{{read of non-const}} expected-note {{in call}}<br>
constexpr E3 e3b(e3);<br>
}<br>
+<br>
+namespace PR21786 {<br>
+ extern void (*start[])();<br>
+ extern void (*end[])();<br>
+ static_assert(&start != &end, ""); // expected-error {{constant expression}}<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div><div dir="ltr"><div><span style="background-color:rgb(255,255,255);color:rgb(68,68,68);font-family:Arial,Helvetica,sans-serif"><b>Indefiant </b>: <a href="http://www.indefiant.com" target="_blank">http://www.indefiant.com</a></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><font color="#999999">Home of Recode : Runtime C++ Editing for VS</font></span></div></div></div>
</font></span></div>
</blockquote></div><br></div>