From mboxrd@z Thu Jan 1 00:00:00 1970 From: abraham@dina.kvl.dk To: gcc-gnats@gcc.gnu.org Cc: abraham@dina.kvl.dk Subject: c++/3331: GCC 3.0, const member pointer error Date: Thu, 21 Jun 2001 08:36:00 -0000 Message-id: <200106211527.RAA15917@zuse.dina.kvl.dk> X-SW-Source: 2001-06/msg00898.html List-Id: >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: