Bug 48289

Summary: [4.5/4.6/4.7 regression] -pedantic breaks std::move
Product: gcc Reporter: Jason Merrill <jason>
Component: c++Assignee: Jason Merrill <jason>
Status: RESOLVED FIXED    
Severity: normal Keywords: rejects-valid
Priority: P3    
Version: 4.6.0   
Target Milestone: 4.6.1   
Host: Target:
Build: Known to work: 4.4.6
Known to fail: 4.5.3, 4.6.0, 4.7.0 Last reconfirmed: 2011-03-25 15:20:36

Description Jason Merrill 2011-03-25 15:18:20 UTC
From https://bugzilla.redhat.com/show_bug.cgi?id=690548

Description of problem:

[18:03:50 pal@underdark ~/tmp/1]$ cat a.cpp
#include <utility>

class A { };

static void g ( A && ) { }

template < class T > class B {
public:
 void f ( ) {
  A a;
  g ( std :: move ( a ) );
 }
};
=================
[18:04:13 pal@underdark ~/tmp/1]$ LANG=C g++ -std=c++0x  -pedantic  -c a.cpp 
a.cpp: In member function 'void B<T>::f()':
a.cpp:11:25: error: invalid initialization of reference of type 'A&&' from
expression of type 'std::remove_reference<A&>::type'
a.cpp:5:13: error: in passing argument 1 of 'void g(A&&)'
=================
error can be fixed by removing -pedantic or by commenting out /*template <
class T > */
Comment 1 Jason Merrill 2011-03-25 16:17:00 UTC
Author: jason
Date: Fri Mar 25 16:16:53 2011
New Revision: 171461

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171461
Log:
	PR c++/48289
	* pt.c (build_non_dependent_expr): Keep dereferences outside the
	NON_DEPENDENT_EXPR.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/move1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-03-25 16:17:41 UTC
Author: jason
Date: Fri Mar 25 16:17:36 2011
New Revision: 171463

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171463
Log:
	PR c++/48289
	* pt.c (build_non_dependent_expr): Keep dereferences outside the
	NON_DEPENDENT_EXPR.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/cpp0x/move1.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/pt.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-03-28 15:06:32 UTC
Author: jason
Date: Mon Mar 28 15:06:28 2011
New Revision: 171607

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171607
Log:
        Revert:
        PR c++/48289
        * pt.c (build_non_dependent_expr): Keep dereferences outside the
        NON_DEPENDENT_EXPR.

Removed:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/cpp0x/move1.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/pt.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Comment 4 Jason Merrill 2011-03-29 14:35:50 UTC
Fixed for 4.6.1.  This patch alone wasn't enough to fix the bug in 4.5, so I'm not going to try to fix it there.