[Bug c++/19982] New: The left side of the "=" operator must be an lvalue.

msadoghi at ca dot ibm dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 16 01:03:00 GMT 2005


Sourc code for t.cpp:
------------------------------------------------
int mymain()
{
	int i = 1;
	int j = 2;
	const volatile int &ri = i;
	const_cast<int *>(&ri) = &j; // error - lvalue required for =
	return 0;
}
------------------------------------------------



Expected Behaviour:
------------------------------------------------
"t.cpp", line 8.25: 1540-2410 (S) The left side of the "=" operator must be an
lvalue.
------------------------------------------------



Actual Behaviour:
------------------------------------------------
t.cpp:6: ISO C++ forbids cast to non-reference type used as lvalue
t.cpp:6: ISO C++ forbids cast to non-reference type used as lvalue
t.cpp:6: confused by earlier errors, bailing out
------------------------------------------------



t.ii generated with -save-temps option
------------------------------------------------
# 1 "t.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.cpp"
int mymain()
{
        int i = 1;
        int j = 2;
        const volatile int &ri = i;
        const_cast<int *>(&ri) = &j;
        return 0;
}

------------------------------------------------




Release:
------------------------------------------------
GCC Version: 3.2.0
------------------------------------------------




Environment:
System Type:
------------------------------------------------
Reading specs from /usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/specs
Configured with: /scratch/gcc-3.2/configure --prefix=/usr/local/gcc.3.2.0
--enable-threads=aix --disable-nls
Thread model: aix
gcc version 3.2
 /usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/cpp0 -lang-c++
-D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -v -iprefix
/usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/ -D__GNUC__=3
-D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D_IBMR2
-D_POWER -D_LONG_LONG -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_IBMR2
-D_POWER -D_LONG_LONG -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -Asystem=unix
-Asystem=aix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_XOPEN_SOURCE=500
-D_XOPEN_SOURCE_EXTENDED=1 -D_LARGE_FILE_API -D_ALL_SOURCE
-D__WCHAR_TYPE__=short unsigned int -D_ARCH_COM
/home/msadoghi/scenario/common/t.cpp t.ii
GNU CPP version 3.2 (cpplib)
ignoring nonexistent directory
"/usr/local/lib/gcc-lib/../../powerpc-ibm-aix5.1.0.0/include"
ignoring nonexistent directory "/usr/local/gcc.3.2.0/powerpc-ibm-aix5.1.0.0/include"
ignoring duplicate directory "/usr/local/gcc.3.2.0/include/c++/3.2"
ignoring duplicate directory
"/usr/local/gcc.3.2.0/include/c++/3.2/powerpc-ibm-aix5.1.0.0"
ignoring duplicate directory "/usr/local/gcc.3.2.0/include/c++/3.2/backward"
ignoring duplicate directory
"/usr/local/gcc.3.2.0/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/../../include/c++/3.2
 /usr/local/lib/gcc-lib/../../include/c++/3.2/powerpc-ibm-aix5.1.0.0
 /usr/local/lib/gcc-lib/../../include/c++/3.2/backward
 /usr/local/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/include
 /usr/local/include
 /usr/local/gcc.3.2.0/include
 /usr/include
End of search list.
 /usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/cc1plus -fpreprocessed
t.ii -quiet -dumpbase t.cpp -version -o t.s
GNU CPP version 3.2 (cpplib)
GNU C++ version 3.2 (powerpc-ibm-aix5.1.0.0)
        compiled by GNU C version 3.2.
/home/msadoghi/scenario/common/t.cpp: In function `int mymain()':
/home/msadoghi/scenario/common/t.cpp:6: ISO C++ forbids cast to non-reference
   type used as lvalue
/home/msadoghi/scenario/common/t.cpp:6: ISO C++ forbids cast to non-reference
   type used as lvalue
/home/msadoghi/scenario/common/t.cpp:6: confused by earlier errors, bailing out
------------------------------------------------




How-To-Repeat:
------------------------------------------------
gcc -v -save-temps -c t.cpp
------------------------------------------------


Notes:
------------------------------------------------
Compilation failure is expected for this test case. However the gcc produces 
an Internal compiler error on AIX which leads to termination of the compilation
process.
------------------------------------------------

-- 
           Summary: The left side of the "=" operator must be an lvalue.
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: msadoghi at ca dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19982



More information about the Gcc-bugs mailing list