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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:36:28+00:00 2026-06-16T11:36:28+00:00

The program will run normally when I try to visit an address which is

  • 0

The program will run normally when I try to visit an address which is already freed. Is there some goods to avoid? like some function named have_alloca(void *p) can return whether p is a valid address.
I know that valgrind with tool=memcheck can do that. But I want to know if I can avoid it from code.
here is a simple example:

#include <stdlib.h>

int main(int argc, char *argv[])
{
    int *p = malloc(sizeof(int) * 10);
    free(p);
    *(p + 1) = 100;

    return 0;
}

Why I can visit a invalid address? and the program can compile and run without any warns.
BTW: Linux.

  • 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-16T11:36:33+00:00Added an answer on June 16, 2026 at 11:36 am

    No, You will have to take care of this yourself.
    Technically, writing to an memory location that does not belong to you is Undefined Behavior from the perspective of the language standard.

    The languages C and C++ provide you the flexibility to reach addresses of variables and play around with them at the expense that it is your responsibility that those addresses contain valid values owned by your variable/object.

    The rationale is:

    “With greater power comes greater responsibility”

    So the responsibility is yours to take.

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

Sidebar

Related Questions

I would like to create a program that will run in background as a
I am about to develop a program which will be installed and run as
I will normally run my Java Program with input file in my current directory.
I have a program that normally run till it terminates, but under some situations,
I am compiling my program that will run on linux gcc 4.4.1 C99. I
I'm writing a simple program that will run entirely client-side. (Desktop programming? do people
Okay so I'm trying to make a little gag program that will run away
I'm implementing a process elevation helper for Windows. It's a program that will run
I have a C# program that will run as a windows scheduled task. This
As we all know Java program will start executing from the public static void

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.