From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13803 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: "Arithmetic exception" with modulus operator '%' Date: Fri, 15 Feb 2019 11:05:27 +0100 Message-ID: <20190215100527.GT21289@port70.net> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="242116"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: "jounijl@yahoo.co.uk" To: musl@lists.openwall.com Original-X-From: musl-return-13819-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 15 11:05:42 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 1guaNK-0010rY-HZ for gllmg-musl@m.gmane.org; Fri, 15 Feb 2019 11:05:42 +0100 Original-Received: (qmail 24195 invoked by uid 550); 15 Feb 2019 10:05:40 -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 24177 invoked from network); 15 Feb 2019 10:05:39 -0000 Mail-Followup-To: musl@lists.openwall.com, "jounijl@yahoo.co.uk" Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:13803 Archived-At: * jounijl@yahoo.co.uk [2019-02-15 03:35:23 +0000]: > As in the headline. Program stops and prints "Arithmetic exception" at the > line where the modulus operator '%' is. >=20 > I'm compiling in Alpine linux with clang installed from apk:s: >=20 > clang -c test.c > clang -o test test.o >=20 > The code is: >=20 > ----- snip ----- > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int unum=C2=A0 =3D 0; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int umod=C2=A0 =3D 0; > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int ures=C2=A0 =3D 0; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ures =3D unum % umod; // <-- t= his one undefined behaviour =3D=3D anything can happen the compiler can drop this entirely. > ----- /snip ----- >=20 > The variables have some values other than 0. >=20 > The environment is: > The Alpine Linux is installed in Oracle Virtualbox in FreeBSD 12, 64-bit > Intel. x86_64 traps mod by 0 (in case the compiler didn't drop the code path because of ub). >=20 > $ uname -a > Linux localhost 4.14.89-0-vanilla #1-Alpine SMP Tue Dec 18 16:10:10 UTC 2= 018 > x86_64 GNU/Linux >=20 > $ clang --version > Alpine clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1) >=20 > What does this? Do I need to include some library? what behaviour do you expect? >=20 > w.b.reg., Jouni