From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13797 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: "Arithmetic exception" with modulus operator '%' Date: Thu, 14 Feb 2019 18:58:14 -0500 Message-ID: <20190214235814.GY23599@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="254856"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: musl@lists.openwall.com To: "jounijl@yahoo.co.uk" Original-X-From: musl-return-13813-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 15 00:58:31 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1guQti-0014Bk-PV for gllmg-musl@m.gmane.org; Fri, 15 Feb 2019 00:58:30 +0100 Original-Received: (qmail 18298 invoked by uid 550); 14 Feb 2019 23:58:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 18280 invoked from network); 14 Feb 2019 23:58:28 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13797 Archived-At: On Fri, Feb 15, 2019 at 03:35:23AM +0000, jounijl@yahoo.co.uk wrote: > > As in the headline. Program stops and prints "Arithmetic exception" > at the line where the modulus operator '%' is. > > I'm compiling in Alpine linux with clang installed from apk:s: > > clang -c test.c > clang -o test test.o > > The code is: > > ----- snip ----- >         unsigned int unum  = 0; >         unsigned int umod  = 0; >         unsigned int ures  = 0; >         ures = unum % umod; // <-- this one > ----- /snip ----- > > The variables have some values other than 0. I don't follow. You say they have some value other than 0, but the above example snippet has them as zero, and if they're 0 it's undefined behavior and a fault of some sort is a typical result. What did you expect to happen? Rich