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

  • Home
  • SEARCH
  • 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 8795733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:27:13+00:00 2026-06-13T23:27:13+00:00

When writing a program, I aim to avoid any unspecified or implementation-defined behaviour. When

  • 0

When writing a program, I aim to avoid any unspecified or implementation-defined behaviour. When linking to C++ libraries, I expect them to have been written in a similar way. If I link to a library that used implementation-defined behaviour when it was compiled, does that instantly make my own program implementation-defined according to the standard?

Does it even matter at this point? If the library has already been compiled to object code, I’m not even dealing with implementation-defined C++ – in fact, it may not have even been written in C++. How about when I use an API that is by its nature platform dependent, such as POSIX?

The way that the standard is written seems to assume my “C++ program” is entirely written by me and involves no other pre-compiled components. How does it accommodate the linking of these components and at what points does the standard stop caring about what my program does?

  • 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-13T23:27:14+00:00Added an answer on June 13, 2026 at 11:27 pm

    If you call a function that has unspecified (or implementation-defined, or undefined) behavior, then your program has unspecified (or implementation-defined, or undefined) behavior.

    The standard does not define what it means for a program “to be implementation-defined”, so I can’t answer that part other than to say no, your program is not implementation-defined according to the standard. Its behavior is.

    If you use call a function from Posix, then your program depends on (that part of) Posix. The behavior of such a program isn’t defined by the C++ standard alone, because the C++ standard doesn’t know or care what the Posix function does. However, given knowledge of what the Posix function does, you can use the C++ standard to work out what the whole program does. So behavior can be defined by the C++ standard, except for the part that’s outside the scope of the C++ standard.

    There are also certain situations where you can make your program have undefined behavior simply by linking to a library, without calling the code in it. Violating the One Definition Rule is the obvious example. So far as the standard is concerned, you’re entitled to define a function called pthread_create, but if you link that program against pthreads, you have undefined behavior.

    There is something of a grey area, whether Posix and other OS functions are “part of the program” or “part of the implementation”. Take for example strdup, which you could easily implement for yourself in a non-Posix environment. If it’s “part of the implementation” then of course its behavior is implementation-defined. If it’s “part of the program” then the behavior of the program is, well, dependent on the program, in common with the behavior of every C++ program! The C++ standard doesn’t really care which way you choose to think of it.

    The standard doesn’t assume anything about how many authors a program has. Provided that the components you use are documented, it’s your responsibility as the person who puts the final program together, to work out whether or not you have used them in a way that makes your program’s behavior as defined as you’d like it to be. If they’re not documented, or they don’t behave as their documentation says they should, then you might like to present a case to their authors that they have a responsibility to do something about that 😉

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

Sidebar

Related Questions

I have been writing a program which asks you to input two integers, which
I have tried writing program that plays a sound file but have been unsuccessful
Im writing a program that should read input via stdin, so I have the
I'm writing a program that handles DBs and writes any changes into ListView for
I've been writing a program in C to move the first 4 bits of
I am writing a program in C++ where I have to calculate the value
I`m writing a program to view product Information in a Listbox. I have a
I am writing a program and have some code inside a string. This code
Good day! I have met problem with synchronizing threads. I am writing program which
I've been writing this program for a while now, and I'm finally ready 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.