http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49395
Summary: Non-class prvalues seem to have cv-qualification with GCC Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: hst...@ca.ibm.com CC: micha...@ca.ibm.com Host: powerpc64-unknown-linux-gnu Target: powerpc64-unknown-linux-gnu C++03 subclause 3.10 [basic.lval] paragraph 9 says that "non-class rvalues always have cv-unqualified types". When compiling with GCC, some forms of expressions producing non-class rvalues still act as if they have cv-qualified type. The test case below is meant to compile clean. ### Self-contained source (a.cpp): volatile int foo(); struct A { volatile int i; }; typedef volatile int vi; volatile int i; const int& ir1 = foo(); const int& ir2 = A().i; // line 8 const int& ir3 = static_cast<volatile int>(i); const int& ir4 = vi(); // line 10 ### Compiler Invocation: g++-4.6.0 -c a.cpp -o a.o ### Compiler output: a.cpp:8:22: error: invalid initialization of reference of type 'const int&' from expression of type 'volatile int' a.cpp:10:21: error: invalid initialization of reference of type 'const int&' from expression of type 'vi' ### g++ -v output: Using built-in specs. Target: powerpc64-unknown-linux-gnu Configured with: ./configure --prefix=/data/gcc --program-suffix=-4.6.0 --disable-libssp --disable-libgcj --enable-version-specific-runtime-libs --with-cpu=default32 --enable-secureplt --with-long-double-128 --enable-shared --enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++,fortran --with-gmp=/usr/local Thread model: posix gcc version 4.6.0 (GCC)