Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Comments

core.lifetime: Fix copyEmplace() wrt. shared/mutability qualifiers#3246

Merged
dlang-bot merged 4 commits intodlang:masterfrom
kinke:copyEmplace
Nov 3, 2020
Merged

core.lifetime: Fix copyEmplace() wrt. shared/mutability qualifiers#3246
dlang-bot merged 4 commits intodlang:masterfrom
kinke:copyEmplace

Conversation

@kinke
Copy link
Contributor

@kinke kinke commented Oct 21, 2020

A tiny follow-up to #3239. Trying to use it in std.variant showed these issues.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + druntime#3246"

@kinke kinke force-pushed the copyEmplace branch 2 times, most recently from 3560c98 to 1f32673 Compare October 21, 2020 20:15
@kinke kinke changed the title core.lifetime: Fix copyEmplace() wrt. shared qualifier core.lifetime: Fix copyEmplace() wrt. shared/mutability qualifiers Oct 21, 2020
assert(t is s);

copyEmplace(si, ti);
assert(ti is si);
Copy link
Contributor Author

@kinke kinke Oct 21, 2020

Choose a reason for hiding this comment

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

Any idea why this assertion above would fail for 32-bit x86 ELF debug (release works)? DMD codegen bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Disabled for DMD x86 Posix now as workaround.

A tiny follow-up to dlang#3239. Trying to use it in std.variant showed this
issue.
Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

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

Looks fine to me, cc @RazvanN7

static if (__traits(isStaticArray, S))
{
enum bool hasElaborateMove = hasElaborateMove!(typeof(S.init[0]));
enum bool hasElaborateMove = S.sizeof && hasElaborateMove!(BaseElemOf!S);
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why length was changed to sizeof?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand how BaseElemOf!S is any different from typeof(S.init[0])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference shows up for multi-dimensional static arrays - BaseElemOf!(float[10][20][30]) == float. - Extracting it as little helper IMO helps to emphasize the intent and may reduce recursive instantiations of these hasElaborate{Move,Destructor,CopyConstructor,Assign} traits; higher dimensions don't matter here except for one of them being 0 and thus making the whole size 0; that's why I've had to change from recursively checking the length of each dimension to checking S.sizeof when passing a static array type and then instantiating the same template once again with the base element type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes total sense. Maybe we should have a test for this so that it does not get modified in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, some tests added.

kinke added 3 commits November 1, 2020 06:27
Corresponding to the front-end's Type.baseElemOf() method.

Use it for some existing traits in that module, minimally fixing/
breaking semantics for `hasIndirections` for empty static arrays (now
always false, independent from base element type).
@RazvanN7 RazvanN7 added the 72h no objection -> merge The PR will be merged if there are no objections raised. label Nov 1, 2020
@thewilsonator
Copy link
Contributor

Given this is blocking other work I'm going to merge it now.

@thewilsonator thewilsonator added auto-merge and removed 72h no objection -> merge The PR will be merged if there are no objections raised. labels Nov 3, 2020
@dlang-bot dlang-bot merged commit be43bd0 into dlang:master Nov 3, 2020
@kinke kinke deleted the copyEmplace branch November 3, 2020 12:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants