Bug 16413 - [3.3 regression] operator() of private member accessible
Summary: [3.3 regression] operator() of private member accessible
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.4
: P2 normal
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2004-07-07 18:36 UTC by David Pritchard
Modified: 2005-04-30 13:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.2.3 3.4.1 4.0.0
Known to fail: 3.3.4
Last reconfirmed: 2005-03-29 01:57:18


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Pritchard 2004-07-07 18:36:26 UTC
The following simple code snippet is correctly rejected by versions 2.95 and
3.2, but is accepted by 3.3:


class A
{
public:
    int operator()(int i) const { return 0; }
};

class B
{
private:
    A a;
};

int main()
{
        return B().a(0);
}



This happens with both const and non-const operator(), but doesn't seem to
happen with other operators. I tried += and operator[], which both correctly
generated errors.
Comment 1 Wolfgang Bangerth 2004-07-07 19:02:05 UTC
Confirmed with 3.3.4. However, this is already fixed in 3.4.1 and mainline.
W.
Comment 2 Gabriel Dos Reis 2004-09-28 13:36:49 UTC
Adjust milestone
Comment 3 Gabriel Dos Reis 2005-04-30 13:48:56 UTC
Access control has been reworked on 3.4.x and is known to be bogus in several
respect in 3.3.x and previous.  Won't fix in 3.3.6.  Suggest upgrade to 3.4.x
or higher.