-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Anonymous wrote:
Hi Folks,
How does the ANSI C++ specification treat the following situation?
char *ptr = new char[25];
ptr += 5;
delete [] ptr;
Will all of the memory be freed? Will only 20 bytes be freed? Is this,
perhaps, undefined?
Thanks!
No, it's not legal.
Just to double-check, I tried it. I get the following error at runtime:
*** glibc detected *** free(): invalid pointer: 0x080497bd ***
Aborted
What exactly are you trying to do?
- --
Regards,
Jonathan Lamothe
/*
* Oops. The kernel tried to access some bad page. We'll have to
* terminate things with extreme prejudice.
*/
die_if_kernel("Oops", regs, error_code);
-- From linux/arch/i386/mm/fault.c
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -
http://enigmail.mozdev.org
iD8DBQFEw21sq9nD47x87JYRAgQiAKCoJ1uLmzZc4LcTSutANe fJbnWDhACfSHQj
PuHLVB+7aOVq6YQVzNRfalE=
=OyX2
-----END PGP SIGNATURE-----