Skip to content

std.path: make .ptr access trusted#4646

Merged
andralex merged 1 commit intodlang:masterfrom
WalterBright:path-trusted
Jul 24, 2016
Merged

std.path: make .ptr access trusted#4646
andralex merged 1 commit intodlang:masterfrom
WalterBright:path-trusted

Conversation

@WalterBright
Copy link
Member

blocker for dlang/dmd#5860

std/path.d Outdated
* pattern[pi0..pi-1] ~ pattern[piRemain..$]
*/
if (pattmp.ptr == null)
if (() @trusted { return pattmp.ptr; }() == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is easy to write safely as pattmp is null. What am I missing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array.ptr is simply rejected by the safety check in the compiler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no .ptr in pattmp is null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble being that ==null can appear in arbitrarily complex forms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no == in pattmp is null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see what you mean. The compiler generates some rather stupid code for array is null. Should be a topic for another issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this as a forcing function for that. e1 is e2 should be @safe for any two slice expressions e1 and e2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember some argument a while back on what array == null should be. Don't remember the details.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't remember the details it doesn't count. e is null is @safe for any slice expression e.

std/path.d Outdated
* pattern[pi0..pi-1] ~ pattern[piRemain..$]
*/
if (pattmp.ptr == null)
if (pattmp == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is is better but I'll choose my battles

@andralex andralex merged commit c027225 into dlang:master Jul 24, 2016
@WalterBright WalterBright deleted the path-trusted branch July 25, 2016 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:Needs Work Review:Trivial typos, formatting, comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants