c++/10668: [diagnostic] assigning address of non-static member variable to pointer

bangerth@dealii.org bangerth@dealii.org
Wed May 7 21:11:00 GMT 2003


Old Synopsis: nested class looks for member variable rather than object
New Synopsis: [diagnostic] assigning address of non-static member variable to pointer

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Wed May  7 21:09:42 2003
State-Changed-Why:
    The compiler is correct. However, the message is confusing:
    it taking the address of c1::i, which is of type int (c1::*).
    This cannot be assigned to a variable of type int*. (NB: why
    does it take the address of a member variable? To take the
    address of a member function, it must always be fully
    specialized, i.e. &X::foo. &foo is not sufficient. Why is it
    here?).
    
    Present 3.4 gives the following message:
    g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
    x.cc: In constructor `c1::c2::c2()':
    x.cc:10: error: `c1::i' is not a member of `c1::c2'
    
    This is not nearly as helpful as icc's message:
    g/x> icc -c x.cc -Xc -ansi
    x.cc(10): error: a nonstatic member reference must be relative to a specific object
          c2() { y = &i; };
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10668



More information about the Gcc-bugs mailing list