Xref: utzoo comp.lang.c:39890 comp.std.c:4907 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!gumby!umich!sharkey!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.lang.c,comp.std.c Subject: Re: Non-Portable pointer assignment? Message-ID: Date: 6 Jun 91 15:13:29 GMT References: <1991Jun5.085138.21366@prl.dec.com> <1991Jun5.150527.22942@klaava.Helsinki.FI> Sender: news@adi.COM Followup-To: comp.std.c Organization: Applied Dynamics International, Inc.; Ann Arbor, Michigan, USA Lines: 42 In-reply-to: wirzeniu@klaava.Helsinki.FI's message of 5 Jun 91 15:05:27 GMT Followups directed to comp.std.c. In article <1991Jun5.150527.22942@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes: Actually, 'x' is an int. (Being picky, I know.) It's not "picky"; it can be crucial. I decided to use `self-documenting code', as it were, to show the space necessary for nul bytes, ',' between concatenated strings, and such. p = malloc(strlen(s) + sizeof '\0'); It took me a while to figure out that I ought to change it to p = malloc(strlen(s) + sizeof (char) '\0'); because sizeof '\0' is 4 on our machines. Because of FlexeLint (with a very rare bug), our non-ANSI compilers, and the fact that it's actually our own MEMmalloc, I actually had to write something like p = MEMmalloc((ulong) strlen(s) + (ulong) sizeof ((char) '\0')); Gak! I just realized, however, that p = malloc(strlen(s) + sizeof ""); should work for ANSI environments. So why in creation was 'x' ever specified to be int? Why not char, with the usual widening in expressions? And why did X3J11 specify that the types of enum constants were int, rather than the same type as the underlying enum type? It is HIGHLY disconcerting to discover that a "character constant" is not of type char, and an "enumeration constant" is not of its enumerated type. -- "Of course he has a knife; he always has a knife. We all have knives. It's 1183 and we're barbarians." Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel