www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2830] New: private attribute doesn't work for structs

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

           Summary: private attribute doesn't work for structs
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: maxmo pochta.ru


tmp1.d
---
private struct TestStruct
{
  int var;
}
---
tmp.d
---
import tmp1;

int main()
{
  TestStruct s;
  s.var=0;
  return 0;
}
---


-- 
Apr 10 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830


gide nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |313, 314
            Summary|private attribute doesn't   |private attribute doesn't
                   |work for structs            |work for
                   |                            |structs/unions/classes




------- Comment #1 from gide nwawudu.com  2009-04-10 09:59 -------
Structs, unions, classes and variables can bypass the private attribute.
Similar to BUG 313 and BUG 314, added dependancies.

tmp1.d
------
private struct TestStruct {
    int var;
}

private union TestUnion {
    int var;
}

private class TestClass {
    int var;
}

private int var;

tmp.d
-----
import tmp1;

void main() {
    TestStruct s;
    TestUnion u;
    auto c = new TestClass;
    s.var = var; // Fails
    s.var = a.var; // OK
}


-- 
Apr 10 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830





------- Comment #2 from jarrett.billingsley gmail.com  2009-04-10 11:17 -------
This is almost certainly a dup of BUG 1441.  The same lack of privacy mechanism
applies to all kinds of UDTs.  It doesn't really have anything to do with BUG
313 or BUG 314.


-- 
Apr 10 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|2.027                       |1.043




------- Comment #3 from smjg iname.com  2009-04-10 14:18 -------
What is 'a'?  That line doesn't seem to have anything to say.

But this code, compiled with the same tmp1.d, has something to say:

----------
import tmp1;

void main() {
    TestStruct s;
    TestUnion u;
    auto c = new TestClass;
    auto sv = s.var;
    auto uv = u.var;
    auto cv = c.var;
    auto v = var;
}


-- 
Apr 10 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830





------- Comment #4 from gide nwawudu.com  2009-04-11 04:11 -------

 tmp.d
 -----
 import tmp1;
 
 void main() {
     TestStruct s;
     TestUnion u;
     auto c = new TestClass;
     s.var = var; // Fails
     s.var = a.var; // OK

// Typo. s.var = tmp1.var; //Compiles but shouldn't bug 314
 }

Looks like a dup of bug 1440, my google-fu is weak. --
Apr 11 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830


maxmo pochta.ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://www.digitalmars.com/d
                   |                            |/2.0/attribute.html#Protecti
                   |                            |onAttribute
          Component|DMD                         |www.digitalmars.com
           Keywords|accepts-invalid             |spec
         OS/Version|Windows                     |All
           Platform|PC                          |All




------- Comment #5 from maxmo pochta.ru  2009-04-11 04:54 -------
^^it's actually my google-fu.

Changing to spec bug. Spec should be clarified, how protection attributes work
in this case.


-- 
Apr 11 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830





------- Comment #6 from smjg iname.com  2009-04-12 17:53 -------
Discussion taken to:
"The great inapplicable attribute debate"
digitalmars.D:87915
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=87915


-- 
Apr 12 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com
            Version|1.043                       |D1 & D2


--- Comment #7 from Jonathan M Davis <jmdavisProg gmx.com> 2011-05-08 14:48:51
PDT ---
This is a bug in both D1 and D2, so I'm marking it as such. TestStruct
shouldn't even be constructable outside of tmp1.d. The question of allowing you
to access its member variables is secondary. It looks like the struct itself is
being left as public, when it should be private. Now, it's still a bug if you
can access its private member variables, but you shouldn't even be able to
construct it in the first place.

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