-
-
Notifications
You must be signed in to change notification settings - Fork 628
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
druntime compiler hooks do not all support copy constructors properly #20970
Labels
Comments
jmdavis
added a commit
to jmdavis/dlang.org
that referenced
this issue
Mar 9, 2025
Until dlang/dmd#20970 is fixed, we need to be warning against the use of copy constructors rather than warning against the use of postblit constructors. So, I fixed the warning and put both it and the description of what happens when mixing postblit constructors and copy constructors together on both the section for postblit constructors and the one for copy constructors. I suspect that move constructors merit a similar warning, but I'm not sure what their current state is, so this just fixes the warning for postblit constructors and copy constructors.
jmdavis
added a commit
to jmdavis/dlang.org
that referenced
this issue
Mar 9, 2025
Until dlang/dmd#20970 is fixed, we need to be warning against the use of copy constructors rather than warning against the use of postblit constructors. So, I fixed the warning and put both it and the description of what happens when mixing postblit constructors and copy constructors together on both the section for postblit constructors and the one for copy constructors. I suspect that move constructors merit a similar warning, but I'm not sure what their current state is, so this just fixes the warning for postblit constructors and copy constructors.
jmdavis
added a commit
to jmdavis/dlang.org
that referenced
this issue
Mar 9, 2025
…ors. Until dlang/dmd#20970 is fixed, we need to be warning against the use of copy constructors rather than warning against the use of postblit constructors. So, I fixed the warning and put both it and the description of what happens when mixing postblit constructors and copy constructors together on both the section for postblit constructors and the one for copy constructors. I suspect that move constructors merit a similar warning, but I'm not sure what their current state is, so this just fixes the warning for postblit constructors and copy constructors.
jmdavis
added a commit
to jmdavis/dlang.org
that referenced
this issue
Mar 11, 2025
…ors. Until dlang/dmd#20970 is fixed, we need to be warning against the use of copy constructors rather than warning against the use of postblit constructors. So, I fixed the warning and put both it and the description of what happens when mixing postblit constructors and copy constructors together on both the section for postblit constructors and the one for copy constructors. I suspect that move constructors merit a similar warning, but I'm not sure what their current state is, so this just fixes the warning for postblit constructors and copy constructors.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm creating this issue so that we have a single issue to point to whereas right now, we have a bunch of related issues. I linked the ones that I found below.
The core problem is that the druntime compiler hooks were not updated to support copy constructors when they were introduced, and the only support that has been added since then is when some of the hooks have been templatized.
TypeInfo
was never updated to know about copy constructors, and so the only hooks that even can know about copy constructors are those which are templates and thus can actually do type introspection on the types being used. In order to fix this situation, eitherTypeInfo
must be updated to know about copy constructors, and all of the hooks that aren't templates need to be updated accordingly, or all of the druntime hooks need to be templatized (with their implementations dealing with copy constructors correctly). And of course, as part of this, we need to actually be testing that all of these various hooks work correctly with types with copy constructors. That testing seems to have been missed completely when copy constructors were introduced - or it was known that it was an issue but just forgotten. Either way, as things stand, code using dynamic arrays or associative arrays cannot safely use copy constructors for any of the elements, keys, or values in those data structures, because their copy constructors will not be called properly in all cases.@teodutu is the one who has done much of the work to templatize the druntime hooks, but as I understand it, he has become quite busy and is not currently working on them. So, we really need to figure out how we're going to solve this if we want this this issue to be solved in a timely manner, and IMHO, as things stand, we have to tell programmers to avoid using copy constructors, because they're broken for dynamic arrays and associative arrays. When I e-mailed Teodor about the hooks previously, this is part of what he told me:
Digging through the list of bugs, these are the bugs that I found which are caused by not all of the hooks supporting copy constructors:
#17487
#17212
#17202
#17454
The are of course other bugs related to copy constructors, postblit constructors, and copying in general, but those are the ones that I found which are clearly caused by the hooks not all dealing with copy constructors properly.
Related to this is that we're now getting move constructors, and
TypeInfo
doesn't understand those either - and I'm not sure that any of the druntime hooks have been updated accordingly either, so I expect that move constructors are in a similar boat, but the copy constructor situation is much more critical IMHO, since we've had them for years, and we've even been claiming in the spec that folks should prefer them to postblit constructors when in fact, they're broken - at least for anyone who's using proper D and not-betterC
. And anyone using move constructors is likely going to want copy constructors anyway.The text was updated successfully, but these errors were encountered: