public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 2.95.2 (g++), member pointer to non-static member array element
@ 2000-07-28  8:36 Tuukka Tikkanen
  0 siblings, 0 replies; only message in thread
From: Tuukka Tikkanen @ 2000-07-28  8:36 UTC (permalink / raw)
  To: gcc

(Seems like the bug submission address in documentation is out of date, so
I'll just blatantly toss this report on to gcc@gcc.gnu.org and hope
maintainers catch it there.)

Hello,

it seems 2.95.2 (and older egcs 1.1.2) release has an interesting bug and
does not allow taking member pointer (offset) of member array element, since
it assumes "&Class::member[]" means taking address (normal) instead of
checking whatever the value is used as member pointer.

Getting this to work would be very useful (and standard conforming :), since
I use it to map textual input names (user input) to class members and in
some cases member array elements.

Tuukka

--- demonstration source ---
class Foo {
public:
  char c1;
  char c2;
  char a[10];
};

int main(int argc, char *argv[])
{
  char Foo::* cp;
  Foo someFoo;

  // Non-array members are OK
  cp = &Foo::c1;
  someFoo.*cp = 42;
  // (another)
  cp = &Foo::c2;
  someFoo.*cp = 13;

  // Following still OK... no subscription
  cp = Foo::a;
  someFoo.*cp = 69;

  // Now the compiler does a bad thing(tm) and misinterprets
  // the expression to mean taking address (illegal) instead
  // of taking offset.
  cp = &Foo::a[5];
  someFoo.*cp = 0;
}
--- cut here ---

g++     bug.C   -o bug
bug.C: In function `int main(int, char **)':
bug.C:5: member `Foo::a' is non-static but referenced as a static member
bug.C:21: at this point in file

gcc version 2.95.2 19991024 (release)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-07-28  8:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-28  8:36 gcc 2.95.2 (g++), member pointer to non-static member array element Tuukka Tikkanen

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).