-
-
Notifications
You must be signed in to change notification settings - Fork 672
fix Issue 15862 - allocating storage in pure functions should not res… #6197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // https://issues.dlang.org/show_bug.cgi?id=15862 | ||
|
|
||
| /* | ||
| PERMUTE_ARGS: | ||
| REQUIRED_ARGS: -O -release | ||
| */ | ||
|
|
||
|
|
||
| int* p() pure nothrow {return new int;} | ||
| int[] a() pure nothrow {return [0];} | ||
| Object o() pure nothrow {return new Object;} | ||
|
|
||
| immutable(int)* pn() pure nothrow {return new int;} | ||
| immutable(int)[] an() pure nothrow {return [0];} | ||
| immutable(Object) on() pure nothrow {return new Object;} | ||
|
|
||
| auto pa() pure nothrow {return new int;} | ||
| auto pb() pure nothrow {return cast(immutable(int)*)(new int);} | ||
|
|
||
| void main() | ||
| { | ||
| { | ||
| int* p1 = p(); | ||
| int* p2 = p(); | ||
|
|
||
| if (p1 is p2) assert(0); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To get those asserts to be ran in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. Thanks.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| int[] a1 = a(); | ||
| int[] a2 = a(); | ||
|
|
||
| if (a1 is a2) assert(0); | ||
|
|
||
| Object o1 = o(); | ||
| Object o2 = o(); | ||
|
|
||
| if (o1 is o2) assert(0); | ||
| } | ||
| { | ||
| auto p1 = pn(); | ||
| auto p2 = pn(); | ||
|
|
||
| if (p1 !is p2) assert(0); | ||
|
|
||
| auto a1 = an(); | ||
| auto a2 = an(); | ||
|
|
||
| if (a1 !is a2) assert(0); | ||
|
|
||
| auto o1 = on(); | ||
| auto o2 = on(); | ||
|
|
||
| if (o1 !is o2) assert(0); | ||
| } | ||
| { | ||
| auto p1 = pa(); | ||
| auto p2 = pa(); | ||
|
|
||
| if (p1 is p2) assert(0); | ||
| } | ||
| { | ||
| auto p1 = pb(); | ||
| auto p2 = pb(); | ||
|
|
||
| if (p1 !is p2) assert(0); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could increase
purityagain, couldn't it? How about replacing the switch withpurity = min(purity, purityOfType(isref, t))?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because any setting of
PUREweakexits the loop.Because there is no reason to continue with the loop once purity is set to
PUREweak.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too clever usage of break/continue in switch nested in a loop IMO.
Hope you agree that
break Lloopis better here :).