Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9314439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:08:02+00:00 2026-06-19T02:08:02+00:00

While examining what exception_ptr does, the C++11 standard says (18.8.5/7) that: Use of rethrow_exception

  • 0

While examining what exception_ptr does, the C++11 standard says (18.8.5/7) that:

Use of rethrow_exception on exception_ptr objects that refer to the same exception object shall not introduce a data race. [ Note: if rethrow_exception rethrows the same exception object (rather than a copy), concurrent access to that rethrown exception object may introduce a data race…

I don’t find the case where this weird “Note” applies, since the described effect of rethrow_exception is “Throws: the exception object to which p refers” but 15.1/3, describing the general exception throwing process mandates that “throwing an exception copy-initializes a temporary object, called the exception object.”

The weird note would imply that rethrow_exception skips this copy-initialization. But is this really possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:08:03+00:00Added an answer on June 19, 2026 at 2:08 am

    Yes, it looks like a deficiency in the standard. For a rethrowing throw-expression i.e. throw; without an operand, 15.1p8 says:

    A throw-expression with no operand rethrows the currently handled exception. The exception is reactivated with the existing exception object; no new exception object is created. […]

    That is:

    #include <exception>
    #include <cassert>
    int main() {
       std::exception *p = nullptr;
       try {
          try {
             throw std::exception();
          } catch(std::exception &ex) {
             p = &ex;
             throw;
          }
       } catch(std::exception &ex) {
          assert(p == &ex);
       }
    }
    

    If the implementation of current_exception copies the currently handled exception object, there’s no way to tell whether rethrow_exception copies or not, but if it refers to the exception object then we can check:

    #include <exception>
    #include <iostream>
    int main() {
       std::exception_ptr p;
       try {
          try {
             throw std::exception();
          } catch(...) {
             p = std::current_exception();
             std::cout << (p == std::current_exception()) << ' ';
             std::rethrow_exception(p);
          }
       } catch(...) {
          std::cout << (p == std::current_exception()) << '\n';
       }
    }
    

    Every implementation I’ve tried it on prints 1 1; 0 0 is allowed if current_exception copies; 0 1 is obviously impossible, while the standard in its current state appears to require 1 0. The fix would be for 18.8.5p10 to be clarified with language similar to 15.1p8, either allowing or mandating rethrow_exception to not copy the exception object pointed to by the exception_ptr.

    Most Throws: specifications in the standard just name a type (Throws: bad_alloc) or use the indefinite article (Throws: an exception of type …); the only other exception specifications to use the definite article are those of future::get and shared_future::get, so any resolution should probably address those as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I inherited a project from a colleague that left the company. While examining his
While examining shader examples I recently found that it's pretty often to pass the
While debugging and keep pressing F5, if the source code does not exist, eclipse
while looking at some code I stumbled onto: throw /*-->*/new std::exception (//... and I
While playing with standard library i've found a strange difference between python2 and python3.
While reading this class BitmapFactory I noticed that almost all methods inside are static.
I am working in C++ with VS2008 and Win7. While examining a program I
While studying computer networks as the course subject, my concept was that operating system
While I believe that there is no actually declared limit and the number of
While examining the instruction set for Intel x86 processors I noticed there are 'intuitive'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.