public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hstong at ca dot ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/49395] New: Non-class prvalues seem to have cv-qualification with GCC
Date: Mon, 13 Jun 2011 20:20:00 -0000	[thread overview]
Message-ID: <bug-49395-4@http.gcc.gnu.org/bugzilla/> (raw)

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)


             reply	other threads:[~2011-06-13 20:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 20:20 hstong at ca dot ibm.com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49395-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).