public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49395] New: Non-class prvalues seem to have cv-qualification with GCC
@ 2011-06-13 20:20 hstong at ca dot ibm.com
  2011-06-22 20:38 ` [Bug c++/49395] " jason at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hstong at ca dot ibm.com @ 2011-06-13 20:20 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: hstong@ca.ibm.com
                CC: michaelw@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)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-05  4:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-13 20:20 [Bug c++/49395] New: Non-class prvalues seem to have cv-qualification with GCC hstong at ca dot ibm.com
2011-06-22 20:38 ` [Bug c++/49395] " jason at gcc dot gnu.org
2011-06-23 16:55 ` jason at gcc dot gnu.org
2011-06-23 17:10 ` jason at gcc dot gnu.org
2012-12-15  4:11 ` jason at gcc dot gnu.org
2024-04-04  6:06 ` pinskia at gcc dot gnu.org
2024-04-05  4:54 ` hstong at ca dot ibm.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).