This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
C++ front end bug: invalid reference initialization allowed
- To: egcs-bugs at cygnus dot com, g++ at cygnus dot com
- Subject: C++ front end bug: invalid reference initialization allowed
- From: Joe Buck <jbuck at Synopsys dot COM>
- Date: Fri, 19 Jun 98 14:34:55 PDT
This example is from a recent discussion on comp.std.c++ .
This input should not be accepted, but is.
const int c = 42;
int* ptr;
int main () {
const int*& refptrToConst = ptr; // should not be allowed!
refptrToConst = &c;
*ptr = 43; // changes c!
}