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 6579863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:57:05+00:00 2026-05-25T15:57:05+00:00

Sorry for the long title, but I think it explains well what I’m interested

  • 0

Sorry for the long title, but I think it explains well what I’m interested in. For example C function strtok is not thread safe in worst possible way 🙂 , it uses a global state. So even if it is called on different data it is not thread safe.
So my question is are there functions in “C++ minus C” that have same problem.
Again I’m not interested in things like “if you write to same file from 10 threads it is undefined behavior”. What I’m interested is “if you write to 2 diff files from 2 diff threads (each thread writes to its own file )that is not thread safe.”

  • 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-05-25T15:57:06+00:00Added an answer on May 25, 2026 at 3:57 pm

    Thread safety is only really covered by C++11; C++03 didn’t specify multi-threaded behavior.

    In C++11, the relevant bits are 1.10/8 “Certain library calls synchronize with other library calls performed by another thread. For example, an atomic store-release synchronizes with a load-acquire that takes its value from the store (29.3).” and especially §17.6.5.9 Data race avoidance.

    The cases you mention are obviously disallowed: “

    1. This section specifies requirements that implementations shall meet to prevent data races (1.10). Every standard library function shall meet each requirement unless otherwise specified. Implementations may prevent data races in cases other than those specified below.
    2. A C++ standard library function shall not directly or indirectly access objects (1.10) accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function’s arguments, including this.
    3. A C++ standard library function shall not directly or indirectly modify objects (1.10) accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function’s nonconst arguments, including this.
    4. [ Note: This means, for example, that implementations can’t use a static object for internal purposes without synchronization because it could cause a data race even in programs that do not explicitly share objects between threads. —end note ]

    Where the text above says “unless otherwise specified”, it includes some C function, e.g. (27.9.2/2) “Calls to the function tmpnam with an argument of NULL may introduce a data race (17.6.5.9) with other calls to tmpnam with an argument of NULL.”

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

Sidebar

Related Questions

Sorry for a long question and not a very descriptive title, but my problem
Sorry for the long title but couldn't think of a good way to put
Sorry for the long winded title, but I think it summaries my problem I
Sorry for the long title, but I couldn't think of another way to put
Sorry for the long title, but it seems most descriptive for my question. Basically,
// stupid title, but I could not think anything smarter I have a code
Sorry for the very long title but it's exactly what I'm looking for. I
Sorry for the long title, didn't want people just reading the title and not
Sorry experts for the title, I could not think of a better way. The
Sorry for how vague the title is, but I'm not completely sure how to

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.