Bug 18607 – using labelled continue in tuple foreach can break pure and @safe
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-13T16:14:41Z
Last change time
2018-03-22T09:24:11Z
Keywords
safe
Assigned to
No Owner
Creator
elpenguino+D
Comments
Comment #0 by elpenguino+D — 2018-03-13T16:14:41Z
int test(T...)() pure {
L:foreach(_; T) {
continue L;
return 1;
}
}
The only return statement in this function is unreachable, so this returns an uninitialized int as long as >= 1 template parameter is specified. This should not have been able to be marked pure.
The pure attribute is automatically inferred but I've explicitly added it here.
Comment #1 by ag0aep6g — 2018-03-13T17:30:27Z
When returning a pointer, this also breaks @safe:
----
int* test(T...)() @safe pure {
L:foreach(_; T) {
continue L;
return null;
}
}
----