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; } } ----
Comment #2 by bugzilla — 2018-03-21T05:13:35Z
Comment #3 by github-bugzilla — 2018-03-22T09:24:10Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/5ccd55ff54eb1c3502f0a435b48c6c63122ce213 fix Issue 18607 - using labelled continue in tuple foreach can break pure and @safe https://github.com/dlang/dmd/commit/b19832e0f150461a5d39204d8efb49871756e38d Merge pull request #8061 from WalterBright/fix18607 fix Issue 18607 - using labelled continue in tuple foreach can break … merged-on-behalf-of: Walter Bright <[email protected]>