473,396 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Unable to delete [] char* in MSVC 6.0

All,

I was wondering why this causes a debug assertion failure in MSVC6.0/EE/SP5:

void main()
{
char* p = "HELLO";
delete [] p;
}

Any ideas?

Thank you!

-Ramiro
Jul 22 '05 #1
2 1517

"Ramiro Barbosa, Jr." <ra******@yahoo.com> wrote in message

I was wondering why this causes a debug assertion failure in MSVC6.0/EE/SP5:
void main()
{
char* p = "HELLO";
delete [] p;


Because you only delete memory obtained through new.

Sharad
Jul 22 '05 #2
I was wondering why this causes a debug assertion failure in MSVC6.0/EE/SP5:
void main()
int main(), don't believe VC6 that accepts void main().
{
char* p = "HELLO";


Also note that the memory pointed by p is non-modifiable (AFAIK, many Unix
compilers place it in some read-only-memory location but this is
implementation dependent). Attempting to modify it is undefined behavior.
Also note that calls to new and new [] operators should be properly matched
by a corresponding call to delete and delete [] operators respectively.
Failing to do so is another cause of Undefined Behavior.

Sharad
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Spikinsson | last post by:
I create a new char and when I attempt to delete it, the debug gives this error (during runtime): Debug Error! Program: xxx DAMAGE: after Normal block (#58) at 0x00C315A0.
21
by: Jakob Bieling | last post by:
Hi, is it possible to get the address of operator new/delete and operator new/delete portably? Otherwise I would have to go for a non-portable and rather unclean solution. Thanks for any...
6
by: Sean Bartholomew | last post by:
i have a bit of a problem. im parsing a record string using strtok but im encountering back to back whitespaces (\t\t) due to empty fields from my database export. the STRTOK function reads up to...
4
by: TK | last post by:
I have encountered a very strange bug. I am using a variable defined as: char ch; If I assigned a character like 'Ö' (ascii 153) with a statement like: ch = 'Ö'; It gets the value -103....
9
by: Jim Langston | last post by:
#include <string> int main () { std::string MyString = "Testing"; MyString = " " + MyString; } This works in Microsoft Visual C++ .net 2003
12
by: ravinderthakur | last post by:
hi experts, i have few questions regarding the delete operator in c++. why does c++ have to operators for deleting memeory viz delete and delete. why cannnot delete be used insted of...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.