microsoft / microsoft/STL

`<functional>`: `move_only_function` behaves differently when constructed with null function pointer in slightly different ways

Open
#5,806 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

The following program:

#include <functional>
#include <print>

int main() {
    std::move_only_function<int(int)> fn1(static_cast<int(*)(int)>(nullptr));
    std::move_only_function<int(int)> fn2(std::in_place_type<int(*)(int)>, nullptr);
    std::print("fn1: {}, fn2: {}", static_cast<bool>(fn1), static_cast<bool>(fn2));
}

Prints:

fn1: false, fn2: true

This is what the Standard is apparently asking for.

Isn't this stupid?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied C++ reproducer and compare the two std::move_only_function constructions described in the issue. No source file or test is named; determine from the Standard whether the differing states are intended, then document the expected outcome before proposing any change.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.