Xref: utzoo comp.lang.c:26705 comp.lang.misc:4374 Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!ccavax!merriman From: merriman@ccavax.camb.com Newsgroups: comp.lang.c,comp.lang.misc Subject: Re: C strongly typed? Message-ID: <19061.25f68d3f@ccavax.camb.com> Date: 8 Mar 90 21:50:07 GMT References: <259@eiffel.UUCP> <1990Mar1.172526.28683@utzoo.uucp> <849@enea.se> <1990Mar7.182230.5517@utzoo.uucp> Organization: Cambridge Computer Associates, Inc. Lines: 55 In article <1990Mar7.182230.5517@utzoo.uucp>, henry@utzoo.uucp (Henry Spencer) writes: > However, if you write something like: > > char *p; > int a; > ... > a = p; > > any modern compiler will object. C's type system is not extensible unless > you count "struct", but the language is strongly typed -- mixing random > types is not allowed. I guess that lets VAX C out as a modern compiler. the following compiles without complaint: #include stdio int i; char c; int *ip; char *cp; main() { i = 700; c = i; printf("%d %d\n", i, c); ip = &i; cp = ip; printf("%d %d\n", *cp, *ip); i = cp; ip = i; printf("%d %d\n", *cp, *ip); } and produces the following output: 700 -68 -68 700 32 544 Anyone care to explain the last line of output? BTW, I included the int to char assignment to demonstrate what I consider to be a really obnoxious and dangerous shortcoming (at least in VAX C). Do real C compilers allow the same thing, without comment?