This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[egcs-19980715] Const pointer reference bug persists.
- To: egcs-bugs at cygnus dot com
- Subject: [egcs-19980715] Const pointer reference bug persists.
- From: Hyman Rosen <hymie at prolifics dot com>
- Date: Wed, 15 Jul 1998 19:42:38 -0400
In the following code, a reference to pointer to const int is
permitted to be directly initialized by a pointer to int. This
breaks const correctness, and is illegal according to the standard.
extern "C" int printf(const char *, ...);
int main(int, char **)
{
volatile const int c = 42;
volatile int *p;
volatile const int *&r = p;
r = &c;
*p = 0;
if (c != 42)
printf("FAILED!\n");
}