[Bug 211] New: Error: iteration 2305843009213693951 invokes undefined behavior
via D.gnu
d.gnu at puremagic.com
Sun Feb 7 12:52:09 PST 2016
http://bugzilla.gdcproject.org/show_bug.cgi?id=211
Bug ID: 211
Summary: Error: iteration 2305843009213693951 invokes undefined
behavior
Product: GDC
Version: development
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: Normal
Component: gdc
Assignee: ibuclaw at gdcproject.org
Reporter: ibuclaw at gdcproject.org
---
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.
--
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20160207/7d9ab773/attachment.html>
More information about the D.gnu
mailing list