Bug 4867 – [GSoC] Postblit is not usable with const objects

Status
RESOLVED
Resolution
WONTFIX
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-09-14T12:32:35Z
Last change time
2019-11-07T07:57:56Z
Assigned to
No Owner
Creator
Max Samukha

Comments

Comment #0 by samukha — 2010-09-14T12:32:35Z
struct S { this(this) { } } void foo(ref const S s) { auto s2 = s; } void main() { } Error: function test.S.__cpctor (ref S p) is not callable using argument types (const(S)) const It is not specified how postblit is supposed to interoperate with const/immutable. Tagging the postblit function with 'const' doesn't help (compilation fails with the same error).
Comment #1 by cristi.cobzarenco — 2011-06-23T12:55:15Z
(In reply to comment #0) > struct S > { > this(this) > { > } > } > > void foo(ref const S s) > { > auto s2 = s; > } > > void main() > { > } > > Error: function test.S.__cpctor (ref S p) is not callable using argument types > (const(S)) const > > It is not specified how postblit is supposed to interoperate with > const/immutable. Tagging the postblit function with 'const' doesn't help > (compilation fails with the same error). The same problem happens when using 'in', as in: void foo( in S s ) { }
Comment #2 by k.hara.pg — 2011-10-09T04:17:47Z
https://github.com/D-Programming-Language/dmd/commit/eb7983c7215b51e5bb719803d48ccf2ed211ab5b Now this issue is resolved, the mutable postblit is called on copied const object. But, this behavior temporarily allows breaking const correctness inside mutable postblit. Therefore, I don't close this issue. Destructor has a similar problem, see bug 4338.
Comment #3 by verylonglogin.reg — 2012-11-03T06:53:04Z
(In reply to comment #2) > But, this behavior temporarily allows breaking const correctness inside mutable > postblit. > Therefore, I don't close this issue. Consolidated into Issue 8956. Do not close this issue as a duplicate because it is another issue. E.g. it can be closed as WONTFIX if postblits will become qualifier-overloadable.
Comment #4 by razvan.nitu1305 — 2019-11-07T07:57:56Z
We have copy constructor now so this is not going to get fix.