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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:18:35+00:00 2026-05-25T19:18:35+00:00

Currently Visual C++ is shipped with runtime where malloc() is decorated with __declspec( restrict

  • 0

Currently Visual C++ is shipped with runtime where malloc() is decorated with __declspec( restrict ).

MSDN says this decoration states to the compiler that a pointer returned by malloc() cannot be aliased by any other pointer. Okay, two subsequent calls to malloc() indeed return distinct pointers. But what happens if I call

void* memory1 = malloc( 10 );
free( memory1 );
void* memory2 = malloc( 10 );
//here memory1 may be equal to memory2

In this case the two pointers can point to the very same location. How does this correlate with cannot be aliased by any other pointer implication of __declspec( restrict )?

  • 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-25T19:18:35+00:00Added an answer on May 25, 2026 at 7:18 pm

    The standard has this to say about “object lifetime” (§3.8 in N3290):

    The lifetime of an object of type T ends when:
    — if T is a class type with a non-trivial destructor (12.4), the destructor call starts, or
    — the storage which the object occupies is reused or released.

    After you’ve free‘d the block pointed to by memory1, that object is dead. It has ceased to exist. Dereferencing that pointer would be undefined behavior.

    memory2 could be assigned the same memory address, but it wouldn’t “alias” anything: what was at that location has passed away.

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

Sidebar

Related Questions

Our dev shop currently uses Visual SourceSafe. We all know how that could end
We are currently evaluating different applications that interface with Visual Studio 2008 (C#) and
I have a Silverlight application that I am maintaining. I am currently using Visual
I am currently using Visual Studio 2008 to develop a hierarchical grid that displays
I am currently using Visual C++ to develop my DLL program. This DLL also
Does anyone have any information on this? I'm currently running Visual Studio Team System
I'm currently running Visual Studio 2008 Standard Edition and one of the items they
I'm evaluating Microsoft Team Foundation Server for my customer, who currently uses Visual SourceSafe
Currently I`m using Visual Studio for writing code in C++. But it seems so
In my work environment, Visual Studio currently crashes every time I start our main

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.