Bug 56285 - [C++11] Arguments to an inheriting constructor are not forwarded properly
Summary: [C++11] Arguments to an inheriting constructor are not forwarded properly
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
: 56317 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-11 11:56 UTC by lucdanton
Modified: 2013-02-14 09:56 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-11 00:00:00


Attachments
Minimal reproducible testcase (101 bytes, text/x-c++src)
2013-02-11 11:56 UTC, lucdanton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lucdanton 2013-02-11 11:56:12 UTC
Created attachment 29417 [details]
Minimal reproducible testcase

$ g++-snapshot --version
g++-snapshot (Debian 20130209-1) 4.8.0 20130209 (experimental) [trunk revision 195917]

$ cat main.cpp 
struct foo {
    explicit foo(int&&) {}
};

struct bar: private foo {
    using foo::foo;
};

int main()
{
    bar b { 42 };
}

$ g++-snapshot -Wall -std=c++11 main.cpp 
main.cpp: In constructor 'bar::bar(int&&)':
main.cpp:6:16: error: cannot bind 'int' lvalue to 'int&&'
     using foo::foo;
                ^
main.cpp:2:14: error:   initializing argument 1 of 'foo::foo(int&&)'
     explicit foo(int&&) {}
              ^
main.cpp: In function 'int main()':
main.cpp:11:16: note: synthesized method 'bar::bar(int&&)' first required here 
     bar b { 42 };
Comment 1 Jonathan Wakely 2013-02-11 13:14:42 UTC
[class.inhctor]/8 says bar should have an implicitly-defined constructor equivalent to 

    bar(int&& p) : foo(static_cast<int&&>(p)) { }
Comment 2 Jason Merrill 2013-02-12 20:47:23 UTC
Author: jason
Date: Tue Feb 12 20:47:15 2013
New Revision: 195990

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195990
Log:
	PR c++/56285
	* method.c (add_one_base_init): Handle base constructor
	taking rvalue reference parm.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/inh-ctor16.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/method.c
Comment 3 Jason Merrill 2013-02-13 02:26:05 UTC
Fixed.
Comment 4 Jonathan Wakely 2013-02-14 09:56:15 UTC
*** Bug 56317 has been marked as a duplicate of this bug. ***