public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3331: GCC 3.0, const member pointer error
@ 2001-06-21 8:36 abraham
0 siblings, 0 replies; only message in thread
From: abraham @ 2001-06-21 8:36 UTC (permalink / raw)
To: gcc-gnats; +Cc: abraham
>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:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-06-21 8:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-21 8:36 c++/3331: GCC 3.0, const member pointer error abraham
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).