This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++ front end bug: invalid reference initialization allowed


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!
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]