[Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.

flast at flast dot jp gcc-bugzilla@gcc.gnu.org
Thu May 19 07:27:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49058

           Summary: [C++0x] Bind no-arguments functor failed using
                    std::bind with -pedantic option.
           Product: gcc
           Version: 4.5.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: flast@flast.jp


GCC rejects following code with -pedantic option.

==== testcase.cc ====
#include <functional>

struct F
{
    void
    operator()();
};

void f()
{
    std::bind( F() );
}
====

==== output ====
$ g++-4.5 -std=c++0x -pedantic testcase.cc
In file included from testcase.cc:1:0:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.4/../../../../include/c++/4.5.4/functional:
In instantiation of 'std::_Bind<F()>':
testcase.cc:11:20:   instantiated from here
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.4/../../../../include/c++/4.5.4/functional:1174:39:
error: no match for call to '(const F) ()'
testcase.cc:5:5: note: candidate is: void F::operator()() <near match>
====

After GCC 4.6, also faild with no-arguments lambda-expression.

==== testcase.cc ====
#include <functional>

void f()
{
    std::bind( []{} );
}
====

==== output ====
$ g++-4.6 -std=c++0x -pedantic testcase.cc
In file included from testcase.cc:1:0:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:
In instantiation of 'std::_Bind<f()::<lambda()>()>':
testcase.cc:5:21:   instantiated from here
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1227:32:
error: no match for call to '(volatile f()::<lambda()>) ()'
testcase.cc:5:17: note: candidates are:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1227:32:
note: void (*)() <conversion>
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1227:32:
note:   candidate expects 0 arguments, 1 provided
testcase.cc:5:17: note: f()::<lambda()> <near match>
testcase.cc:5:17: note:   no known conversion for implicit 'this' parameter
from 'volatile f()::<lambda()>*' to 'const f()::<lambda()>*'
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:
In instantiation of 'std::_Bind<f()::<lambda()>()>':
testcase.cc:5:21:   instantiated from here
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1240:38:
error: no match for call to '(const volatile f()::<lambda()>) ()'
testcase.cc:5:17: note: candidates are:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1240:38:
note: void (*)() <conversion>
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1240:38:
note:   candidate expects 0 arguments, 1 provided
testcase.cc:5:17: note: f()::<lambda()> <near match>
testcase.cc:5:17: note:   no known conversion for implicit 'this' parameter
from 'const volatile f()::<lambda()>*' to 'const f()::<lambda()>*'
====

gcc-4.5 (GCC) 4.5.4 20110512 (prerelease) - Failed
gcc-4.6 (GCC) 4.6.1 20110513 (prerelease) - Failed
gcc-4.7 (GCC) 4.7.0 20110517 (experimental) - Failed



More information about the Gcc-bugs mailing list