Skip to content

Issue with std::function conversion #886

Closed

Description

@os12

Consider:

void TestAndRun(folly::Function<void()> f) {
  if (f) f();
}

The following usage works perfectly:

  TestAndRun([]{});
  TestAndRun({});
  TestAndRun(nullptr);

The following gets past the if check and results in "bad_function_call" exception thrown by std::function:

TestAndRun(std::function<void()>());

Also, it seems the behavior varies with build/optimization settings - sometimes things work.

Activity

  1. added a commit that references this issue on Mar 4, 2019
    b94044f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions