public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yvan ROUX <yvan.roux@st.com>
To: <gcc@gcc.gnu.org>
Subject: [4.6 branch] Issue with C++ references.
Date: Tue, 18 Oct 2011 15:20:00 -0000	[thread overview]
Message-ID: <20111018135738.GC2871@gnb.st.com> (raw)

Hi,

I have the small program below, which check the binding of a reference :

int main() {
        const int Ci = 0;
        const int &rCi = Ci;
        if (!(&Ci == &rCi)) return 1;
        return 0;
}

If my understanding of the standard (8.5.3) is correct, the reference is
an lvalue (rCi), the initializer expression (Ci) is an lvalue and the two 
referenced types are the same => rCi is bound to Ci, my program is a
valid one. If this is not the case, the rest of this mail could be skip.
 
The program has the expected behaviour if you use a 4.5 gcc or the trunk, but
if you compile it with a 4.6 one (even with the branch's head) with -O0,
the program returns the 1 value, because rCi is not bound to Ci, but to an
anonymous temporary which cantains the value 0. 

The problem was introduced during the integration of the constexpr support,
in the cp_parser_initializer_clause function of the parser.c file, with the 
commit :
Git : ce984e5e401accb43a1c4bfee31a4743f4004118
Svn : trunk@166167

and was fixed on the trunk by the commit :
Git : 5e260adbb1f177a25a39691d3e4510d6bc3b898a
Svn : trunk@175284

In fact only the part of the commit which removes the call to 
maybe_constant_value in cp_parser_initializer_clause fixes the bug.
I'm not really sure of what I have to do in such a case :
peparing the patch or asking to backport Jason's on the 4.6 branch ?


Many Thanks

Yvan

             reply	other threads:[~2011-10-18 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18 15:20 Yvan ROUX [this message]
2011-10-19  5:46 ` Jason Merrill
2011-10-19 12:57   ` Yvan ROUX

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=20111018135738.GC2871@gnb.st.com \
    --to=yvan.roux@st.com \
    --cc=gcc@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).