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]

const reference bug - Is there anyone out there?


I've reported the following bug several times, but have seen absolutely
no responses, so I don't know whether it's being ignored, or whether it's
been filed away for future examination. Could someone please say?

The compiler allows a reference to pointer to const T to be directly
initialized with a pointer to T. This breaks const-correctness, and
allows const objects to be silently modified. Here's the test case:

extern "C" int printf(const char *, ...);
int main()
{
	volatile const int c = 42;
	volatile int *p;
	volatile const int *&r = p;
	r = &c;
	*p = 0;
	if (c != 42)
		printf("FAILED!\n");
}


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