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 12:34:29 -0800 Organization: None to speak of Lines: 31 Message-ID: References: <87oa1yljof.fsf@bsb.me.uk> <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> 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/7eArJt9kASnKLmsmuAC/L" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:jnT1SbOXoufv7yo3bG0c7pqBdwk= sha1:RAdtOPlN72hPa7obrRRfW3Yhzlw= Xref: csiph.com comp.lang.c:96640 supercat@casperkitty.com writes: > On Tuesday, November 15, 2016 at 12:51:41 PM UTC-6, Tim Rentsch wrote: >> supercat writes: >> > Dennis Ritchie seems to have planned that integer overflow would wrap >> > around on the PDP-11 implementation, [...] >> >> s/planned/noticed/ > > His printf code tests for -32768 by checking if a variable isn't zero but > negating it leaves the value unmodified. That would make no sense if he > didn't plan on the PDP wrapping what should be +32768 to -32768. Dennis Ritchie didn't invent the PDP-11. He observed its behavior and happened to write a printf implementation that depends on that behavior. I don't know what meaningful distinction you're trying to make between "planned" and "noticed". I haven't looked at the code in question, but if it's as you describe it obviously wouldn't work on a system with 32-bit int, even with straightforward two's-complement behavior. 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. -- 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"