"do ... while ((NULL + 1) - 1);" -- valid C?

Ruud Harmsen ruud at targon.UUCP
Tue Aug 22 19:09:00 AEST 1989


In article <781 at janus.UUCP> casper at fwi.uva.nl (Casper H.S. Dik) writes:
>> The char-pointer gets its value from malloc, and I never change that char-
>> pointer other than by adding multiples of sizeof(int) to it.  Is a "ip =
>> cp" guaranteed safe under these conditions, so can I ignore the compiler-
>> warning?
>No. It is not safe. If you ever want to run your program on a Data General
>MV, among others, you should use "ip = (int *) cp".

You're right, of course.  As a matter of fact, I did use the cast in my
program.  Sorry I didn't mention that in the original article.

	Ruud Harmsen



More information about the Comp.lang.c mailing list