Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: usecases of void foo(char **b) {} Date: Tue, 15 Nov 2016 13:43:39 -0800 Organization: None to speak of Lines: 52 Message-ID: References: <4c243d9f-8b30-4c8f-aeb7-f98b67df53df@googlegroups.com> <2609ed15-7c52-4d08-bf8c-2b9ef44fa809@googlegroups.com> <89e9cc99-3b51-44f1-91bc-f74b6f2b7f5a@googlegroups.com> <34d35fa8-fe94-4665-b0e1-21de4f507fe4@googlegroups.com> <52475847-d45a-4c24-9661-1ebe869759b3@googlegroups.com> <6c6a30d0-94cd-42a6-884a-2ac99995e681@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="de46ff73fe43b8b35b0550d5525951b1"; logging-data="9452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SYLm3r5ycwS//wQmRJu2t" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:hOf8RtxQFWjd6Jj/U3ERzC3x1wU= sha1:YgMrKOU8YYOaIEHshvLiV4wbCr8= Xref: csiph.com comp.lang.c:96648 supercat@casperkitty.com writes: [...] >> His PDP-11 printf implementation clear was not intended to be 100% >> portable, which was a perfectly legitimate design choice. He was also >> relying on his knowledge of how the compiler portion of the >> implementation behaved. > > It was intended to be portable to implementations targeting hardware > platforms similar to the PDP-11. I don't think he intended that it be > restricted to use on C implementations which expressly promise to expose > the platform's underlying silent-wraparound behavior to the program, since > his own C implementation didn't expressly promise that. At least in modern terms, his printf function was part of the same implementation as the C compiler. It doesn't matter what the C compiler expressly promised. He was justified in relying on its actual behavior, which I suspect he knew extremely well. Rather than making assumptions about what Dennis Ritchie intended, I prefer to rely on what he actually wrote. (The following is manually re-typed, and any errors are mine.) K&R1 A.7 (1978): The handling of overflow and divide check in expression evaluation is machine-dependent. All existing implementations of C ignore integer overflows; treatment of division by 0, and all floating-point exceptions, varies between machines, and is usually adjustable by a library function. I infer from the phrase "All *existing* implementations" that he was allowing for the possibility that future implementations could legitimately behave differently. K&R2 A.7 (1988): The handling of overflow, divide check, and other exceptions in expression evaluation is not defined by the language. Most existing implementations of C ignore overflow in evaluation of signed integral expressions and assignments, but this behavior is not guaranteed. Treatment of division by 0, and all floating-point exceptions, varies among implementations; sometimes it is adjustable by a non-standard library function. (Probably "conversions" would have been more accurate than "assignments".) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"