Skip to content

Conversation

monarchdodra
Copy link
Collaborator

This fixes issue 9974 in points to, amongst other issues:

unions: Named unions are now correctly taken into account.
classes: These are handle the same as if they were pointers.
alias this: A subtle bug: An alias this could make pointsTo take the wrong path, analyzing the alias, rather than the actual source. The fix is to really check IsA as opposed to "Convertible to". In particular: "isPointer".

Improved on documentation to avoid pitfalls.

Reworked the restraints: It makes 0 sense to pass target by value, so that was banned. Source was expanded to accept by value pointers and classes.

@monarchdodra
Copy link
Collaborator Author

Could I get a review, or feedback on this? There was actually very little code change, and plenty of unittests to validate the new changes.

If $(D source) is or contains a dynamic array, then, then pointsTo will check
if there is overlap between the dynamic array and $(D target)'s representation.

If $(D source) is or contains a union, then every member of the union is
Copy link
Contributor

Choose a reason for hiding this comment

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

Is access to non-set union fields even legal under the D spec? IIRC it isn't in C.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AFAIK, it's not illegal, its just implementation defined.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I thought it was _un_defined behavior. But as I can't find the relevant paragraph in the spec right now, I'll trust you on that (and it's unclear in how this would apply to D anyway).

@monarchdodra
Copy link
Collaborator Author

I just added some documented unittests. They are thorough, but might be overkill?

Also, why is pointsTo in std.exception ? That don't make no sense to me. I'd have though std.typecons.d.

@jmdavis
Copy link
Member

jmdavis commented Jun 16, 2013

I just added some documented unittests. They are thorough, but might be overkill?

Maybe, but I'll merge it.

Also, why is pointsTo in std.exception ? That don't make no sense to me. I'd have though std.typecons.d.

Probably for the same reason that assumeUnique is in std.exception. Whoever created it (probably Andrei) didn't know where else to put it, and there's a decent chance that it was std.contracts at the time (as listed in TDPL) rather than std.exception after we renamed it. Whatever the exact reason is, it's likely historical and doesn't ultimately make sense, but it is what it is at this point unless we think that it's worth breaking code to move it around.

jmdavis added a commit that referenced this pull request Jun 16, 2013
Fix Issue 9975 - pointsTo asserts because of false pointer in union
@jmdavis jmdavis merged commit af14a7f into dlang:master Jun 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants