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
* [Bug c++/55908] Problem binding a const member function to a const object
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 ` redi at gcc dot gnu.org
2013-01-08 13:35 ` [Bug c++/55908] [4.8 Regression] " redi at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-08 13:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55908
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2013-01-08
AssignedTo|unassigned at gcc dot |redi at gcc dot gnu.org
|gnu.org |
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-08 13:33:56 UTC ---
Reduced:
#include <functional>
struct foo
{
void f(int) const
{
}
void g() const
{
auto mf = std::mem_fn(&foo::f);
mf(this, 1);
}
};
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/55908] [4.8 Regression] Problem binding a const member function to a const object
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 ` 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
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-08 13:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55908
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.7.3
Target Milestone|--- |4.8.0
Summary|Problem binding a const |[4.8 Regression] Problem
|member function to a const |binding a const member
|object |function to a const object
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-08 13:35:18 UTC ---
Will fix it later today.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/55908] [4.8 Regression] Problem binding a const member function to a const object
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
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-08 21:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55908
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-08 21:01:23 UTC ---
Author: redi
Date: Tue Jan 8 21:01:14 2013
New Revision: 195035
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195035
Log:
PR libstdc++/55908
* include/std/functional (_Mem_fn::operator()): Fix constraints to
avoid ambiguity.
* testsuite/20_util/function_objects/mem_fn/55908.cc: New.
* testsuite/20_util/bind/ref_neg.cc: Adjust dg-error line numbers.
Added:
trunk/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55908.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/functional
trunk/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/55908] [4.8 Regression] Problem binding a const member function to a const object
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
` (2 preceding siblings ...)
2013-01-08 21:01 ` redi at gcc dot gnu.org
@ 2013-01-08 21:04 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-08 21:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55908
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-08 21:03:57 UTC ---
Fixed, thanks for the report.
^ 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).