public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
@ 2011-12-04  7:31 roman at binarylife dot net
  2011-12-04 15:26 ` [Bug c++/51406] " redi at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: roman at binarylife dot net @ 2011-12-04  7:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

             Bug #: 51406
           Summary: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of
                    static_cast to rvalue reference to base class.
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: roman@binarylife.net


$ cat test.cpp 
#include <stdlib.h>
#include <iostream>

struct A { int a; A() : a(1) {} };
struct B { int b; B() : b(2) {} };
struct X : A, B {};

int main() {
    X x;
    int a=static_cast<A&&>(x).a;
    int b=static_cast<B&&>(x).b;
    std::cout<<"a="<<a<<", b="<<b<<std::endl;
    if (a!=1 || b!=2) abort();
}

$ g++ -std=c++0x test.cpp && ./a.out 
a=1, b=1
Aborted


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
@ 2011-12-04 15:26 ` redi at gcc dot gnu.org
  2011-12-05  9:36 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-04 15:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-04 15:26:07 UTC ---
the conversions create unnecessary temporaries

    int&& a = static_cast<A&&>(x).a;
    int&& b = static_cast<B&&>(x).b;
    std::cout<<"a="<<&a<<", b="<<&b<<std::endl;

shows they have the same address


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
  2011-12-04 15:26 ` [Bug c++/51406] " redi at gcc dot gnu.org
@ 2011-12-05  9:36 ` rguenth at gcc dot gnu.org
  2011-12-05 11:38 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-05  9:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Target Milestone|---                         |4.5.4


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
  2011-12-04 15:26 ` [Bug c++/51406] " redi at gcc dot gnu.org
  2011-12-05  9:36 ` rguenth at gcc dot gnu.org
@ 2011-12-05 11:38 ` paolo.carlini at oracle dot com
  2011-12-06 14:29 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-05 11:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-05
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-05 11:38:28 UTC ---
When fixing this bug we may want to have a look to PR51161


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (2 preceding siblings ...)
  2011-12-05 11:38 ` paolo.carlini at oracle dot com
@ 2011-12-06 14:29 ` rguenth at gcc dot gnu.org
  2011-12-14  5:09 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-06 14:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (3 preceding siblings ...)
  2011-12-06 14:29 ` rguenth at gcc dot gnu.org
@ 2011-12-14  5:09 ` jason at gcc dot gnu.org
  2011-12-14  6:02 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-14  5:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (4 preceding siblings ...)
  2011-12-14  5:09 ` jason at gcc dot gnu.org
@ 2011-12-14  6:02 ` jason at gcc dot gnu.org
  2011-12-14 16:05 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-14  6:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-14 05:18:47 UTC ---
Author: jason
Date: Wed Dec 14 05:18:39 2011
New Revision: 182322

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182322
Log:
    PR c++/51406
    PR c++/51161
    * typeck.c (build_static_cast_1): Fix cast of lvalue to
    base rvalue reference.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/rv-cast3.C
    trunk/gcc/testsuite/g++.dg/cpp0x/rv-cast4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (5 preceding siblings ...)
  2011-12-14  6:02 ` jason at gcc dot gnu.org
@ 2011-12-14 16:05 ` jason at gcc dot gnu.org
  2011-12-14 16:06 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-14 16:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-14 16:03:45 UTC ---
Author: jason
Date: Wed Dec 14 16:03:37 2011
New Revision: 182340

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182340
Log:
    PR c++/51406
    PR c++/51161
    * typeck.c (build_static_cast_1): Fix cast of lvalue to
    base rvalue reference.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/cpp0x/rv-cast3.C
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/cpp0x/rv-cast4.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/typeck.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (6 preceding siblings ...)
  2011-12-14 16:05 ` jason at gcc dot gnu.org
@ 2011-12-14 16:06 ` jason at gcc dot gnu.org
  2011-12-14 16:36 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-14 16:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-14 16:03:16 UTC ---
Author: jason
Date: Wed Dec 14 16:03:07 2011
New Revision: 182339

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182339
Log:
    PR c++/51406
    PR c++/51161
    * typeck.c (build_static_cast_1): Fix cast of lvalue to
    base rvalue reference.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/rv-cast3.C
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/rv-cast4.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/typeck.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (7 preceding siblings ...)
  2011-12-14 16:06 ` jason at gcc dot gnu.org
@ 2011-12-14 16:36 ` jason at gcc dot gnu.org
  2011-12-17  9:13 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-14 16:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-14 16:34:19 UTC ---
Fixed for 4.5.4, 4.6.3, 4.7.0.


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (8 preceding siblings ...)
  2011-12-14 16:36 ` jason at gcc dot gnu.org
@ 2011-12-17  9:13 ` ubizjak at gmail dot com
  2011-12-17 11:41 ` mikpe at it dot uu.se
  2011-12-17 14:24 ` jason at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2011-12-17  9:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

--- Comment #7 from Uros Bizjak <ubizjak at gmail dot com> 2011-12-17 07:28:59 UTC ---
The testcases use "target c++11" target selector.  This selector is not known
on 4.6 and earler branches.  The testcases fail as following on 4.6 branch [1]:

Running target unix
ERROR: g++.dg/cpp0x/rv-cast3.C: syntax error in target selector "target c++11"
for " dg-do 2 run { target c++11 } "
UNRESOLVED: g++.dg/cpp0x/rv-cast3.C: syntax error in target selector "target
c++11" for " dg-do 2 run { target c++11 } "
ERROR: g++.dg/cpp0x/rv-cast4.C: syntax error in target selector "target c++11"
for " dg-do 2 compile { target c++11 } "
UNRESOLVED: g++.dg/cpp0x/rv-cast4.C: syntax error in target selector "target
c++11" for " dg-do 2 compile { target c++11 } "

[1] http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg01771.html


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (9 preceding siblings ...)
  2011-12-17  9:13 ` ubizjak at gmail dot com
@ 2011-12-17 11:41 ` mikpe at it dot uu.se
  2011-12-17 14:24 ` jason at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: mikpe at it dot uu.se @ 2011-12-17 11:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

--- Comment #8 from Mikael Pettersson <mikpe at it dot uu.se> 2011-12-17 11:31:33 UTC ---
(In reply to comment #7)
> The testcases use "target c++11" target selector.  This selector is not known
> on 4.6 and earler branches.  The testcases fail as following on 4.6 branch [1]:
> 
> Running target unix
> ERROR: g++.dg/cpp0x/rv-cast3.C: syntax error in target selector "target c++11"
> for " dg-do 2 run { target c++11 } "
> UNRESOLVED: g++.dg/cpp0x/rv-cast3.C: syntax error in target selector "target
> c++11" for " dg-do 2 run { target c++11 } "
> ERROR: g++.dg/cpp0x/rv-cast4.C: syntax error in target selector "target c++11"
> for " dg-do 2 compile { target c++11 } "
> UNRESOLVED: g++.dg/cpp0x/rv-cast4.C: syntax error in target selector "target
> c++11" for " dg-do 2 compile { target c++11 } "

I see the exact same failures with 4.5 branch on all targets I'm testing.


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

* [Bug c++/51406] [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class.
  2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
                   ` (10 preceding siblings ...)
  2011-12-17 11:41 ` mikpe at it dot uu.se
@ 2011-12-17 14:24 ` jason at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-17 14:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51406

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-17 14:23:20 UTC ---
Oops.  Fixed, thanks.


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

end of thread, other threads:[~2011-12-17 14:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-04  7:31 [Bug c++/51406] New: [4.5/4.6/4.7 Regression][c++0x] Incorrect result of static_cast to rvalue reference to base class roman at binarylife dot net
2011-12-04 15:26 ` [Bug c++/51406] " redi at gcc dot gnu.org
2011-12-05  9:36 ` rguenth at gcc dot gnu.org
2011-12-05 11:38 ` paolo.carlini at oracle dot com
2011-12-06 14:29 ` rguenth at gcc dot gnu.org
2011-12-14  5:09 ` jason at gcc dot gnu.org
2011-12-14  6:02 ` jason at gcc dot gnu.org
2011-12-14 16:05 ` jason at gcc dot gnu.org
2011-12-14 16:06 ` jason at gcc dot gnu.org
2011-12-14 16:36 ` jason at gcc dot gnu.org
2011-12-17  9:13 ` ubizjak at gmail dot com
2011-12-17 11:41 ` mikpe at it dot uu.se
2011-12-17 14:24 ` jason at gcc dot gnu.org

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