This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/3331: GCC 3.0, const member pointer error



>Number:         3331
>Category:       c++
>Synopsis:       member pointer inherits const
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 21 08:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.0
>Organization:
Church of Emacs
>Environment:
System: SunOS zuse 5.8 Generic_108528-02 sun4u sparc SUNW,Ultra-Enterprise
Architecture: sun4

	
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../configure --prefix=/usr/pack/gcc-3.0-lj
>Description:

The following code gets an "assignment of read-only location" on line
12.  As far as I can see, "b" should be read only (because bars is
read-only), but the objectc pointed to by "b" should not.  I'm no C++
language lawyer though.

The code compile fine with GCC 2.95, Borland C++ 5.0 and Visual C++ 6.0.

----------------- test.cpp -----------------------
struct foo
{ 
  int a;

  struct bar
  { int foo::* b ;};

  static const bar bars[];

  int bad ()
  {
    this->*(bars[0].b) = 42; // error: assignment of read-only location
  }
};

const foo::bar foo::bars[] = { { &foo::a } };

int main ()
{ }
--------------------------------------------------

>How-To-Repeat:

compile with "c++ test.cpp"

>Fix:
As a workaround, don't make "bars" read only.

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]