This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/48541] New: std::function(std::_Function_base) should use std::addressof


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

           Summary: std::function(std::_Function_base) should use
                    std::addressof
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: n.fujita12@gmail.com


In std::_Function_base::_M_get_pointer, operator & is used to get a pointer of
the functor.
So, some callable objects which override operator & and they don't return their
pointer couldn't be held by std::function.

----
struct X {
  void operator ()() const {
    std::cerr << "X()\n";
  }
  float operator &() const {
    return 1.2345;
  }
};
int main() {
  X x;
  std::function<void ()> f(x);
  return 0;
}
----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]