Jump to page: 1 2
Thread overview
[Issue 2830] New: private attribute doesn't work for structs
Apr 10, 2009
d-bugmail
[Issue 2830] private attribute doesn't work for structs/unions/classes
Apr 10, 2009
d-bugmail
Apr 10, 2009
d-bugmail
Apr 10, 2009
d-bugmail
Apr 11, 2009
d-bugmail
Apr 11, 2009
d-bugmail
Apr 12, 2009
d-bugmail
May 08, 2011
Jonathan M Davis
Jan 23, 2012
Walter Bright
Jan 23, 2012
Jonathan M Davis
Jan 23, 2012
Walter Bright
Sep 05, 2012
Walter Bright
Oct 18, 2012
Oleg Kuporosov
April 10, 2009
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;
}
---


-- 

April 10, 2009
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
}


-- 

April 10, 2009
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.


-- 

April 10, 2009
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;
}


-- 

April 11, 2009
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.


-- 

April 11, 2009
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.


-- 

April 12, 2009
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


-- 

May 08, 2011
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: -------
January 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2830


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|spec                        |
                 CC|                            |bugzilla@digitalmars.com


--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2012-01-23 00:36:23 PST ---
It's not a spec bug. Private declarations should not be visible outside their module.

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



--- Comment #9 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-01-23 07:51:48 PST ---
> It's not a spec bug. Private declarations should not be visible outside their module.

Do you mean not visible or not accessible? At present, private seems to work like C++ in that it's _always_ visible but not accessible. It's included in overload sets too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2