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





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






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





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







 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





^^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






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 next 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



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
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jan 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830




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: -------
Jan 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830




11:25:49 PST ---
I meant accessible.

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 & D2                     |D1



22:17:05 PDT ---
Fix for D2: https://github.com/D-Programming-Language/dmd/pull/163

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2830


Oleg Kuporosov <Oleg.Kuporosov gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Oleg.Kuporosov gmail.com



22:08:03 PDT ---
Peter's fixes from "Comment 11" is verified in dmd2.061 alpha, but looks wasn't
merged into D1 branch, so tests still failed in dmd1.076 alpha. This record wss
issued against D1 so status is unchanged.

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