www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3089] New: Error: f.bar can only be called on a mutable object, not shared(foo)

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3089

           Summary: Error: f.bar can only be called on a mutable object,
                    not shared(foo)
           Product: D
           Version: 2.030
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jason.james.house gmail.com


Created an attachment (id=401)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=401)
Sample code demonstrating the issue

The compiler seems to offer no way to call functions on shared structs/classes
under certain scenarios.  The attached code demonstrates the simplest case I
could find.  Changing the type of foo to class, or moving the shared keyword on
the function bar has no effect.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 23 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3089


Rob Jacques <sandford jhu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandford jhu.edu
         OS/Version|Linux                       |All




--- Comment #1 from Rob Jacques <sandford jhu.edu>  2009-08-07 14:43:50 PDT ---
I've found const functions are callable on shared objects:

struct foo{
  int bar() const { return 1; }
}

void main(){
  shared foo f;
  auto x = f.bar;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 07 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3089



--- Comment #2 from Sobirari Muhomori <dfj1esp02 sneakemail.com> 2009-10-28
09:55:31 PDT ---
That's because struct has no monitor member, so the callee can't lock it for
exclusive access.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 28 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3089



--- Comment #3 from Rob Jacques <sandford jhu.edu> 2009-10-28 10:06:11 PDT ---
To the best of my knowledge, currently, shared does not imply synchronized,
though synchronized implies shared. Shared only provides the correct memory
fences. Shared structs/arrays are important for lock-free algorithms.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 28 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3089



--- Comment #4 from Jason House <jason.james.house gmail.com> 2009-10-28
10:55:53 PDT ---
(In reply to comment #3)
 To the best of my knowledge, currently, shared does not imply synchronized,
 though synchronized implies shared. Shared only provides the correct memory
 fences. Shared structs/arrays are important for lock-free algorithms.

That's the exact use case I want to do! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 28 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3089


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |WORKSFORME


--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2009-10-28
11:30:10 PDT ---
Works in dmd 2.035.

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