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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:15:02+00:00 2026-05-13T06:15:02+00:00

Possible Duplicates: Why is there a special new and delete for arrays? ( POD

  • 0

Possible Duplicates:
Why is there a special new and delete for arrays?
( POD )freeing memory : is delete[] equal to delete ?

What’s the result if I use delete p instead of delete [] p for an array?
I met two answers for this problem.

1 only the first element will be freed.

2 there comes to a catastrophic end.

My question is, how can this two happen? Why there would be a disaster if only the first element is freed? Can anybody offer me an example?

  • 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-13T06:15:02+00:00Added an answer on May 13, 2026 at 6:15 am

    It is undefined behavior.

    What this means is that the standard gurantees to the writers of the memory management library that certain pre-conditions exist (In this case that arrays will be deleted with delete []).

    If you break these pre-conditions then the memory management library could fail in some way. How it fails will depend on how the library is implemented. But since C++ is designed for speed the result is probably not going to be nice. So usually this means that the internal memory management data structures are corrupted in some way. This will probably lead to some other part of your program sigfaulting.

    If you build in debug mode (on some compilers) they will use a special version of the memory management library that is designed to be more robust. Thus in these situations you may not crash but the extra checks have been explicitly added to the library and as a result is slower. But you still can not gurantee correct behavior.

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

Sidebar

Related Questions

Possible Duplicates: Is there a problem that has only a recursive solution? Can every
Possible Duplicates: Formatting of if Statements Is there a best coding style for identations
Possible Duplicates: Finding duplicate files and removing them. In Python, is there a concise
Possible Duplicate: Is there any working memory profiler for Python3 I have some script
Possible Duplicates: Is there a string math evaluator in .NET? Converting string expression to
Possible Duplicates: Is there any advantage of being a case-sensitive programming language? Why are
Possible Duplicates: Why are there sometimes meaningless do/while and if/else statements in C/C++ macros?
Possible Duplicates: In Javascript, what does it mean when there is a logical operator
Possible Duplicate: ASP.NET “special” tags Is there a proper name for <%...> in ASP.NET,
Possible Duplicates: Is there a difference between !== and != in PHP? Javascript ===

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.