This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/62115] [5 Regression] ICE with invalid default argument
- From: "roman.perepelitsa at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Nov 2014 21:37:05 +0000
- Subject: [Bug c++/62115] [5 Regression] ICE with invalid default argument
- Auto-submitted: auto-generated
- References: <bug-62115-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62115
Roman Perepelitsa <roman.perepelitsa at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |roman.perepelitsa at gmail dot com
--- Comment #4 from Roman Perepelitsa <roman.perepelitsa at gmail dot com> ---
r216124 has also fixed another bug, which may result in valid code being
rejected and also in incorrect code generation for valid code.
#include <utility>
struct Base { int value; };
struct Derived : Base {};
void Foo(int&&) {}
int main() {
Derived d;
Foo(std::move(d).value);
}
Before r216124 this program produced the following compile error:
test.cc: In function 'int main()':
test.cc:10:25: error: cannot bind 'int' lvalue to 'int&&'
Foo(std::move(d).value);
^
test.cc:6:6: error: initializing argument 1 of 'void Foo(int&&)'
void Foo(int&&) {}
If function Foo() was overloaded for const int& and int&, or if it used perfect
forwarding, it would result in successful compilation and incorrect runtime
behaviour.
Would it be possible to backport the fix to gcc-4_9-branch?