-
-
Notifications
You must be signed in to change notification settings - Fork 381
Document Placement NewExpression #4161
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
If it is not appropriate to merge in 72 hours, feel free to take off the tag. |
2c73e49
to
eb6cbf0
Compare
I cannot merge it anyway until the dmd PR is merged, as otherwise the code examples will not work. |
@WalterBright Is this ready to be merged now? |
are designed to be on the GC heap. The size of the associative array allocated is determined | ||
by the runtime library, and cannot be set by the user.) | ||
|
||
$(P The use of $(PlacementExpression) is not allowed in `@safe` code.) |
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.
Fix ddoc macro error
$(P The use of $(PlacementExpression) is not allowed in `@safe` code.) | |
$(P The use of $(I PlacementExpression) is not allowed in `@safe` code.) |
} | ||
----------- | ||
|
||
$(H4 $(LNAME2 PlacementExpression, Placement Expression)) |
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.
PlacementExpression is already a GNAME anchor above.
$(H4 $(LNAME2 PlacementExpression, Placement Expression)) | |
$(H4 $(LNAME2 placement-expression, Placement Expression)) |
$(P $(I NewExpression)s allocate memory on the | ||
$(DDLINK spec/garbage, Garbage Collection, garbage | ||
collected) heap by default. | ||
collected) heap unless there is a $(RELATIVE_LINK2 PlacementExpression, PlacementExpression). |
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.
Change to match subheading anchor fix below:
collected) heap unless there is a $(RELATIVE_LINK2 PlacementExpression, PlacementExpression). | |
collected) heap unless there is a $(RELATIVE_LINK2 placement-expression, *PlacementExpression*). |
--- | ||
) | ||
|
||
(If Type is a class, the $(I PlacementExpression) must produce an lvalue of type that is of a |
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.
(If Type is a class, the $(I PlacementExpression) must produce an lvalue of type that is of a | |
(If Type is a class, the $(I PlacementExpression) must produce an lvalue of a type that is of a |
|
||
void main() | ||
{ | ||
void[__traits(classInstanceSize, C)] k; |
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.
Fix "Error: variable onlineapp.main.k
of type void[24]
does not have a default initializer"
void[__traits(classInstanceSize, C)] k; | |
void[__traits(classInstanceSize, C)] k = void; |
void[__traits(classInstanceSize, C)] k; | ||
C c = new(k) C; | ||
assert(c.j == 4); | ||
assert(cast(void*)c == cast(void*)k.ptr); |
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.
I think the second cast isn't needed.
assert(cast(void*)c == cast(void*)k.ptr); | |
assert(cast(void*) c == k.ptr); |
$(P The lifetime of the object presented as an lvalue ends with the execution of the $(I NewExpression), | ||
and a new lifetime of the placed object starts after the execution.) | ||
|
||
$(SPEC_RUNNABLE_EXAMPLE_COMPILE |
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.
All 3 examples should be SPEC_RUNNABLE_EXAMPLE_RUN, so the auto-tester checks the asserts.
PR: dlang/dmd#17057