<html>
<head>
<base href="http://bugzilla.gdcproject.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 - Error: iteration 2305843009213693951 invokes undefined behavior"
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=211">211</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Error: iteration 2305843009213693951 invokes undefined behavior
</td>
</tr>
<tr>
<th>Product</th>
<td>GDC
</td>
</tr>
<tr>
<th>Version</th>
<td>development
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>Normal
</td>
</tr>
<tr>
<th>Component</th>
<td>gdc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>ibuclaw@gdcproject.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ibuclaw@gdcproject.org
</td>
</tr></table>
<p>
<div>
<pre>---
struct Array
{
void setlength(size_t nlength)
{
foreach (ref val; ptr[nlength .. length])
val = 0;
}
void insertBack()
{
setlength(length + 1);
}
size_t* ptr;
size_t length;
}
---
This causes an warning/error to be emitted under optimizations. (-O2 -Werror)
---
array.d: In function ‘insertBack’:
array.d:5:9: error: iteration 2305843009213693951 invokes undefined behavior
[-Werror=aggressive-loop-optimizations]
foreach (ref val; ptr[nlength .. length])
^
array.d:5:9: note: within this loop
foreach (ref val; ptr[nlength .. length])
^
---
This is the codegen:
---
while (1)
{
ulong & val;
if (!(__aggr40.length > __key41)) break;
val = __aggr40.ptr + __key41 * 8;
*val = 0;
__key41 = __key41 + 1;
}
---
I think this could be vastly improved by initializing the reference directly,
rather than via a modify expression.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are watching all bug changes.</li>
</ul>
</body>
</html>