What does new uint8_t(64) do? Do POD types have constructors?
I made a mistake in a code. I wrote something like:
uint8_t * var = new uint8_t(64);
instead of:
uint8_t * var = new uint8_t[64];
The compiler (gcc) did not complain, but at execution, I get a SEGFAULT
with this message:
... free(): invalid next size (fast): ...
Running with valgrind (memchecker): I get the following diagnostic:
Invalid write of size 8
I tried this with gcc 4.7.2, producing a 64-bit executable, running on
Linux. I also tried with gcc 4.5.2, producing a 32-bit executable and I
get the same kind of issue and diagnostic.
It looks like some memory gets allocated, but not the amount indicated
between the parenthesis.
What did I actually do?
No comments:
Post a Comment