<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - char * const initialized with new char[strlen]() causes assertion failure for 32-bit targets"
href="https://bugs.llvm.org/show_bug.cgi?id=47143">47143</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>char * const initialized with new char[strlen]() causes assertion failure for 32-bit targets
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>john.brawn@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>When the following example is compiled for a 32-bit target (I see it happening
with --target=arm or i686 but not --target=aarch64 or x86_64)
extern "C" {
unsigned int strlen(const char * s);
}
char *fn() {
char * const ptr = new char[strlen("bla")]();
return ptr;
}
then it causes the assertion failure
clang/lib/AST/ExprConstant.cpp:9089: bool (anonymous
namespace)::PointerExprEvaluator::VisitCXXNewExpr(const clang::CXXNewExpr *):
Assertion `CAT && "unexpected type for array initializer"' failed.
Doesn't happen if ptr isn't const, or if the function in the new char[] isn't
strlen, or if we have just new char[strlen("bla")] with no () after it.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>