Thread overview
[Issue 4867] New: Postblit is not usable with const objects
Sep 14, 2010
Max Samukha
Jun 23, 2011
Cristi Cobzarenco
[Issue 4867] [GSoC] Postblit is not usable with const objects
Oct 09, 2011
Kenji Hara
Nov 03, 2012
Denis Shelomovskij
September 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4867

           Summary: Postblit is not usable with const objects
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: samukha@voliacable.com


--- Comment #0 from Max Samukha <samukha@voliacable.com> 2010-09-14 12:32:35 PDT ---
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).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4867


Cristi Cobzarenco <cristi.cobzarenco@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cristi.cobzarenco@gmail.com


--- Comment #1 from Cristi Cobzarenco <cristi.cobzarenco@gmail.com> 2011-06-23 12:55:15 PDT ---
(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 ) {

}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4867



--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-09 04:17:47 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4867


Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg@gmail.com


--- Comment #3 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-11-03 16:53:04 MSK ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------