From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 19A223858410; Mon, 23 Oct 2023 17:37:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19A223858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1698082670; bh=khWqPlp8Bi0W+o2cGS9KudtriozTwXuezIxEhXRRiiw=; h=From:To:Subject:Date:From; b=yzUUSCmVBphOv3ACh9cdyeoq1BT7eThwhcOsw+xEyJkPl5urifdBh3pFgtHRe+tcE AiqRjGqjq5l1RvWQafgn3LiQJY1n/1XmtEO/UFWXqADfLzfWi6IDA38DdMoHaj7MMH XlhsC1cSf33rD/6+7McmQy3Jhjo/GAIJ2q75TvNU= From: "bruno at clisp dot org" To: glibc-bugs@sourceware.org Subject: [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 Date: Mon, 23 Oct 2023 17:37:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.35 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30990 Bug ID: 30990 Summary: fesetexceptflag raises floating-point exception traps on i386, x86_64 Product: glibc Version: 2.35 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: bruno at clisp dot org CC: drepper.fsp at gmail dot com Target Milestone: --- Created attachment 15189 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15189&action=3Ded= it test case foo.c According to ISO C 23 =C2=A7 7.6.4.5, fesetexceptflag is supposed to set floating-point exception flags without raising a trap. "Like fesetexcept, this function does not raise floating-point exceptions, but only sets the state of the flags." That's not how glibc's implementation does it on 32-bit x86, 64-bit x86_64,= and powerpc/powerpc64/powerpc64le. The powerpc/powerpc64/powerpc64le case is already being handled in https://sourceware.org/bugzilla/show_bug.cgi?id=3D30988 . Therefore here le= t me concentrate on x86 and x86_64. How to reproduce: 1. Compile the attached program foo.c. Compiling for 64-bit mode on x86_64 hosts, or for 32-bit mode on i386 hosts: $ gcc -Wall foo.c -lm Compiling for 32-bit mode on x86_64 hosts: $ i686-linux-gnu-gcc -Wall foo.c -lm or $ gcc -m32 -Wall foo.c -lm 2. Run it. $ ./a.out Floating point exception I think it is a hardware limitation that on i386 and x86_64 CPUs, setting a floating-point exception flag in the 387 unit triggers a trap, when traps are enabled for the particular exception. But setting a floating-point exception flag in the SSE unit does not have this problem, cf. glibc/sysdeps/x86_64/fpu/fesetexcept.c. Therefore I would expect the fesetexceptflag() function to operate correctly when the hardware has an SSE unit (determined e.g. like in sysdeps/i386/fpu/ftestexcept.c). And only in the case where the CPU has only the 387 unit, I would expect the fesetexceptflag() function to return a non-zero value (as error indicat= or) and not modify the 387 floating-point control register, when this is the only way to avoid a trap. --=20 You are receiving this mail because: You are on the CC list for the bug.=