Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: integer divided by zero Date: Mon, 28 Apr 2025 13:44:03 -0700 Organization: None to speak of Lines: 36 Message-ID: <871ptc10fg.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 28 Apr 2025 22:44:05 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e2b3c7eff28fe954ba39316719062df0"; logging-data="90204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/v/LGV6DN1Csm/laJEiyCV" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:MpuE6he+Jl+SlE+9Uz+9Izcoq4E= sha1:miVnUe7HrGL7N+aqVxUUMbFpVzw= Bytes: 1942 Richard Heathfield writes: > On 25/04/2025 18:38, Thiago Adams wrote: >> Does anyone know of any platform where integer division by zero >> returns a number, or in other words, where it's not treated as an >> error? I'm asking because division by zero is undefined behaviour, >> but I think division by a constant zero should be a constraint >> instead. > > C? I doubt it very much. I showed an example earlier in this thread. A simpler example: $ uname -ms Linux aarch64 $ cat c.c #include #include int main(int argc, char **argv) { if (argc != 3) exit(EXIT_FAILURE); const int a = atoi(argv[1]); const int b = atoi(argv[2]); printf("%d / %d = %d\n", a, b, a/b); } $ ./c 100 7 100 / 7 = 14 $ ./c 1 0 1 / 0 = 0 $ ./c 0 0 0 / 0 = 0 $ -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */