public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55908] New: Problem binding a const member function to a const object
@ 2013-01-08 13:17 sefi@s-e-f-i.de
2013-01-08 13:34 ` [Bug c++/55908] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: sefi@s-e-f-i.de @ 2013-01-08 13:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55908
Bug #: 55908
Summary: Problem binding a const member function to a const
object
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sefi@s-e-f-i.de
The following code fails to compile:
#include <functional>
typedef std::function<void (int) >func;
struct foo
{
void f(int) const
{
}
void g() const
{
func(std::bind(&foo::f, this, std::placeholders::_1));
}
};
int main()
{
}
g++-4.8.0-alpha20130106 -std=c++11 test.cpp
test.cpp: In member function 'void foo::g() const':
test.cpp:14:55: error: no matching function for call to
'std::function<void(int)>::function(std::_Bind_helper<false, void
(foo::*)(int)const, const foo* const, const std::_Placeholder<1>&>::type)'
func(std::bind(&foo::f, this, std::placeholders::_1));
^
test.cpp:14:55: note: candidates are:
In file included from test.cpp:1:0:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2252:2:
note: template<class _Functor, class> std::function<_Res(_ArgTypes
...)>::function(_Functor)
function(_Functor);
^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2252:2:
note: template argument deduction/substitution failed:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2227:7:
note: std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes
...)>&&) [with _Res = void; _ArgTypes = {int}]
function(function&& __x) : _Function_base()
^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2227:7:
note: no known conversion for argument 1 from 'std::_Bind_helper<false, void
(foo::*)(int)const, const foo* const, const std::_Placeholder<1>&>::type {aka
std::_Bind<std::_Mem_fn<void (foo::*)(int)const>(const foo*,
std::_Placeholder<1>)>}' to 'std::function<void(int)>&&'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2430:5:
note: std::function<_Res(_ArgTypes ...)>::function(const
std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {int}]
function<_Res(_ArgTypes...)>::
^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2430:5:
note: no known conversion for argument 1 from 'std::_Bind_helper<false, void
(foo::*)(int)const, const foo* const, const std::_Placeholder<1>&>::type {aka
std::_Bind<std::_Mem_fn<void (foo::*)(int)const>(const foo*,
std::_Placeholder<1>)>}' to 'const std::function<void(int)>&'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2207:7:
note: std::function<_Res(_ArgTypes ...)>::function(std::nullptr_t) [with _Res =
void; _ArgTypes = {int}; std::nullptr_t = std::nullptr_t]
function(nullptr_t) noexcept
^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2207:7:
note: no known conversion for argument 1 from 'std::_Bind_helper<false, void
(foo::*)(int)const, const foo* const, const std::_Placeholder<1>&>::type {aka
std::_Bind<std::_Mem_fn<void (foo::*)(int)const>(const foo*,
std::_Placeholder<1>)>}' to 'std::nullptr_t'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2200:7:
note: std::function<_Res(_ArgTypes ...)>::function() [with _Res = void;
_ArgTypes = {int}]
function() noexcept
^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-alpha20130106/include/g++-v4/functional:2200:7:
note: candidate expects 0 arguments, 1 provided
The problem goes away if the int parameter is taken out, or if g() is not
const.
gcc-4.7.2 accepts the test case.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-08 21:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-08 13:17 [Bug c++/55908] New: Problem binding a const member function to a const object sefi@s-e-f-i.de
2013-01-08 13:34 ` [Bug c++/55908] " redi at gcc dot gnu.org
2013-01-08 13:35 ` [Bug c++/55908] [4.8 Regression] " redi at gcc dot gnu.org
2013-01-08 21:01 ` redi at gcc dot gnu.org
2013-01-08 21:04 ` redi 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).