Herbert Rosenau said:
On Fri, 17 Mar 2006 18:44:03 UTC, "Vladimir S. Oka"
Liar! Never ever cast the return value of a function returning void* -
except you likes to land in the world of undefined behavior.
Vladimir accidentally typed "Yes" when he clearly meant "No". This
has already been pointed out and acknowledged. Possibly you didn't
see that, but it should have been obvious from the rest of what he
wrote.
Liar! There IS a mayor difference (<any cast>) malloc() results in
undefined behavor, p=malloc() is the only secure call allowed in C.
Nonsense. Calling malloc() with no prototype in scope causes
undefined behavior (at least in C90). Applying a correct cast does
not make the behavior any more or less defined.
For example, the following:
#include <stdlib.h>
int main(void)
{
int *ptr = (int*)malloc(sizeof(int));
return 0;
}
is perfectly valid; the cast is unnecessary, but harmless. (The cast
is harmful if it converts the result to the wrong type, or if it masks
a failure to include <stdlib.h>, or if it masks a failure to use a C
compiler rather than a C++ compiler. All these can be easy mistakes
to make, which is why we strongly discourage casting the result of
malloc().)
And a very few people have valid reasons to write code that will
compile as both C and C++; for them, the cast (done carefully) is
mandatory.
However, I'm going to assume that this was an honest mistake on your
part. I'm going to resist the temptation to call you a liar, with or
without an exclamation point.
Conceivably this is a language problem. To be clear, by using the
word "liar", you are accusing Vladimir of deliberately, maliciously,
and knowingly making false statements. This is extraordinarily rude
on your part, as well as being wrong.
You owe Vladimir (and the rest of us) an apology.