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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:49:41+00:00 2026-06-05T03:49:41+00:00

What does the OS/Debugger do when a pointer is assigned 0?

  • 0

What does the OS/Debugger do when a pointer is assigned 0?

  • 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-05T03:49:44+00:00Added an answer on June 5, 2026 at 3:49 am

    The essential problem this solves is that not all CPU’s implement the same sorts of memory dereference semantics. In some cases, it’s not possible to make dereferencing an address after it has been free() into anything that looks like an error. This is especially true on embedded processors. In other cases, allocators may be very lazy about returning freed memory to the host operating system, for performance reasons.

    Fundamentally, dereferencing such a pointer could lead to actually seeing the freed region, seeing a zeroed out region, seeing memory that has been returned by a subsequent allocation, or causing a cpu exception. Since such an eventuality is completely reasonable, c++ has assigned this condition as “undefined behavior”.

    To get out of that situation, you want to have a way of distinguishing pointer values which have been freed or allocated. As such, C++ requires that dereferencing a pointer that has been assigned 0 is an error, and converting such a pointer to an integer also return zero.


    re: your current edit.

    pointers don’t exist for the purposes of operating systems. At the lowest level, there are no strings, integers, floats or pointers of any sort. only bytes. When you write a c++ program that assigns 0 to a pointer value, the operating system simply doesn’t enter into the equation. that’s totally up to the compiler implementation.

    On the other hand, when you dereference such a pointer in your program, c++ requires that this is be a runtime error. On embedded systems, that’s basically not practical, 0 is a perfectly valid memory address on such systems, usually the SRAM is near that address. If the compiler strictly implements the standard, it might insert a check before every dereference to see if it was null, and put the MCU in an error state, but that’s unusual, since it would slow an already slow system and increase program size.

    On more fully featured systems, those that have a memory management unit, the zero address in the application is usually not mapped to any physical page, so the operating system does help you here, by raising a segfault in the page program when it tries to access the null pointer value.

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

Sidebar

Related Questions

I am working on OpenCL. Does anyone know of a good debugger for OpenCL
Does the front buffer pointer now points to the back buffer?Or the front buffer
When I set a breakpoint in a class then access a method, debugger does
The first example does not work when you go to delete the pointer. The
I wish to print a Stack<Integer> object as nicely as the Eclipse debugger does
The debugger does not locate the line of the exception, its either to deep
I am seeing debug statements in the console but the debugger does not stop
Does anybody know an open source C++ debugger for Windows? It doesn't have to
How does one get Safari's debugger to persist a breakpoint across a page refresh?
Why does this objective-c code print 0's for the values, where as in debugger

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.