public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [4.6 branch] Issue with C++ references.
@ 2011-10-18 15:20 Yvan ROUX
  2011-10-19  5:46 ` Jason Merrill
  0 siblings, 1 reply; 3+ messages in thread
From: Yvan ROUX @ 2011-10-18 15:20 UTC (permalink / raw)
  To: gcc

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

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

end of thread, other threads:[~2011-10-19  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-18 15:20 [4.6 branch] Issue with C++ references Yvan ROUX
2011-10-19  5:46 ` Jason Merrill
2011-10-19 12:57   ` Yvan ROUX

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).