public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23904] New: Const function selection
@ 2005-09-15 21:45 dsell at agleader dot com
  2005-09-15 21:51 ` [Bug c++/23904] " pinskia at gcc dot gnu dot org
  2005-09-15 21:53 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: dsell at agleader dot com @ 2005-09-15 21:45 UTC (permalink / raw)
  To: gcc-bugs

class OtherClass;

class MyClass
{
public:
	const OtherClass* GetOther() const { return ( m_other_p ); }

protected:
	OtherClass* GetOther() { return ( m_other_p ); }

	OtherClass *m_other_p;

	friend class FriendClass;
};

In this case friend classes are allowed to access non-const data, but other
classes can only access the const data. The problem is that the compiler does
not recognize that other classes can call the GetOther() const function. It only
tries to use the non-const version and reports that the function is protected.
The two classes do have different C-V qualifiers so they have different
signatures. There is a workaround for this bug that you can declare a pointer to
a const MyClass and then call GetOther() which forces the compiler to look for a
const version of the function.

-- 
           Summary: Const function selection
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dsell at agleader dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23904


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/23904] Const function selection
  2005-09-15 21:45 [Bug c++/23904] New: Const function selection dsell at agleader dot com
@ 2005-09-15 21:51 ` pinskia at gcc dot gnu dot org
  2005-09-15 21:53 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-15 21:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-15 21:51 -------
Namelookup happens before access checking.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23904


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/23904] Const function selection
  2005-09-15 21:45 [Bug c++/23904] New: Const function selection dsell at agleader dot com
  2005-09-15 21:51 ` [Bug c++/23904] " pinskia at gcc dot gnu dot org
@ 2005-09-15 21:53 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-15 21:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-15 21:53 -------
As I mentioned in comment 1, this is not a bug as namelookup comes before access checking.  This is 
what the standard says.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23904


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-15 21:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-15 21:45 [Bug c++/23904] New: Const function selection dsell at agleader dot com
2005-09-15 21:51 ` [Bug c++/23904] " pinskia at gcc dot gnu dot org
2005-09-15 21:53 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).