boost::future handles std::exception differently from std::future on Windows

Open
#325 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start by running the provided VC++2019 Windows reproduction and compare boost::async with std::async. Trace the boost::async future path through f1.get() and the exception handling involved. Done means the boost path preserves the original std::exception::what() message, matching the shown std::async behavior.

Written by the indexing model from the issue text.

Description

I'm using VC++2019, I use boost::when_all since std::when_all is not available yet. But I find that boost::async will discard std::exception::what() and use 'Unknown exception' or 'std::exception' instead, on the other hand, std::async could handle the message as expected.

#include <iostream>

#define BOOST_THREAD_PROVIDES_FUTURE
#include <boost/thread/future.hpp>

#include <future>

int main() {
    auto f1 = boost::async([]{ // the program will print 'my exception' if this line uses 'std::async'.
        try{
            throw std::invalid_argument("my exception");
        }
        catch (const std::exception& e) {
            throw e;
        }
    });

    try {
        f1.get();
    }
    catch (const std::exception& e) {
        std::cout << e.what() << std::endl;
    }
}

Dominant language
C++
Stars
213
Forks
171
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

More from boostorg/thread

All issues in boostorg/thread

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.