public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39036] New: Decimal floating-point exception flags done wrong
@ 2009-01-30 2:00 tydeman at tybor dot com
2009-01-30 2:41 ` Andrew Thomas Pinski
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: tydeman at tybor dot com @ 2009-01-30 2:00 UTC (permalink / raw)
To: gcc-bugs
Using gcc 4.3.2-7 on Intel Pentium 4 running Linux Fedora Core 10 and
-std=gnu99
/* DFP TR 24732 == WG14 / N1176, N1312 */
#define __STDC_WANT_DEC_FP__ /* Tell implementation that we want Decimal FP */
#pragma STDC FENV_ACCESS ON /* will be testing FP exception flags */
#include <stdio.h> /* printf() */
#include <fenv.h> /* fetestexcept(), FE_* */
#include <float.h> /* DEC*_MIN, DEC*_MAX */
int main(void){
_Decimal64 d10;
int before;
int after;
before = feclearexcept( FE_ALL_EXCEPT );
d10 = 1.0DD;
d10 /= 3.0DD;
after = fetestexcept( FE_ALL_EXCEPT );
if( FE_INEXACT & after ){
printf("Inexact raised as expected\n");
}else{
printf("Inexact wrong; after=%i\n", after);
}
before = feclearexcept( FE_ALL_EXCEPT );
d10 = DEC64_MIN;
d10 *= d10;
after = fetestexcept( FE_ALL_EXCEPT );
if( FE_UNDERFLOW & after ){
printf("Underflow raised as expected\n");
}else{
printf("Underflow wrong; after=%i\n", after);
}
before = feclearexcept( FE_ALL_EXCEPT );
d10 = DEC64_MAX;
d10 *= d10;
after = fetestexcept( FE_ALL_EXCEPT );
if( FE_OVERFLOW & after ){
printf("Overflow raised as expected\n");
}else{
printf("Overflow wrong; after=%i\n", after);
}
before = feclearexcept( FE_ALL_EXCEPT );
d10 = DEC64_MIN;
d10 /= (d10-d10);
after = fetestexcept( FE_ALL_EXCEPT );
if( FE_DIVBYZERO & after ){
printf("Divbyzero raised as expected\n");
}else{
printf("Divbyzero wrong; after=%i\n", after);
}
before = feclearexcept( FE_ALL_EXCEPT );
d10 = 0.0e-15DD;
d10 /= d10;
after = fetestexcept( FE_ALL_EXCEPT );
if( FE_INVALID & after ){
printf("Invalid raised as expected\n");
}else{
printf("Invalid wrong; after=%i\n", after);
}
printf("%2i = FE_INEXACT\n", FE_INEXACT);
printf("%2i = FE_UNDERFLOW\n", FE_UNDERFLOW);
printf("%2i = FE_OVERFLOW\n", FE_OVERFLOW);
printf("%2i = FE_DIVBYZERO\n", FE_DIVBYZERO);
printf("%2i = FE_INVALID\n", FE_INVALID);
return 0;
}
gets:
Inexact wrong; after=0
Underflow wrong; after=0
Overflow wrong; after=32
Divbyzero wrong; after=0
Invalid wrong; after=0
32 = FE_INEXACT
16 = FE_UNDERFLOW
8 = FE_OVERFLOW
4 = FE_DIVBYZERO
1 = FE_INVALID
--
Summary: Decimal floating-point exception flags done wrong
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tydeman at tybor dot com
GCC host triplet: 4.3.2
GCC target triplet: 4.3.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/39036] Decimal floating-point exception flags done wrong
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
2009-01-30 2:41 ` Andrew Thomas Pinski
@ 2009-01-30 2:41 ` pinskia at gmail dot com
2009-01-30 7:20 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gmail dot com @ 2009-01-30 2:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gmail dot com 2009-01-30 02:41 -------
Subject: Re: New: Decimal floating-point exception flags done wrong
Sent from my iPhone
On Jan 29, 2009, at 6:00 PM, "tydeman at tybor dot com"
<gcc-bugzilla@gcc.gnu.org
> wrote:
> Using gcc 4.3.2-7 on Intel Pentium 4 running Linux Fedora Core 10 and
> -std=gnu99
There were some dfp fixes on the trunk relating to fp exceptions so
you should try the trunk before reporting any more bugs.
>
>
> /* DFP TR 24732 == WG14 / N1176, N1312 */
> #define __STDC_WANT_DEC_FP__ /* Tell implementation that we want
> Decimal FP */
> #pragma STDC FENV_ACCESS ON /* will be testing FP exception
> flags */
>
> #include <stdio.h> /* printf() */
> #include <fenv.h> /* fetestexcept(), FE_* */
> #include <float.h> /* DEC*_MIN, DEC*_MAX */
>
>
> int main(void){
> _Decimal64 d10;
> int before;
> int after;
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = 1.0DD;
> d10 /= 3.0DD;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_INEXACT & after ){
> printf("Inexact raised as expected\n");
> }else{
> printf("Inexact wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = DEC64_MIN;
> d10 *= d10;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_UNDERFLOW & after ){
> printf("Underflow raised as expected\n");
> }else{
> printf("Underflow wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = DEC64_MAX;
> d10 *= d10;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_OVERFLOW & after ){
> printf("Overflow raised as expected\n");
> }else{
> printf("Overflow wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = DEC64_MIN;
> d10 /= (d10-d10);
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_DIVBYZERO & after ){
> printf("Divbyzero raised as expected\n");
> }else{
> printf("Divbyzero wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = 0.0e-15DD;
> d10 /= d10;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_INVALID & after ){
> printf("Invalid raised as expected\n");
> }else{
> printf("Invalid wrong; after=%i\n", after);
> }
>
> printf("%2i = FE_INEXACT\n", FE_INEXACT);
> printf("%2i = FE_UNDERFLOW\n", FE_UNDERFLOW);
> printf("%2i = FE_OVERFLOW\n", FE_OVERFLOW);
> printf("%2i = FE_DIVBYZERO\n", FE_DIVBYZERO);
> printf("%2i = FE_INVALID\n", FE_INVALID);
>
> return 0;
> }
>
> gets:
>
> Inexact wrong; after=0
> Underflow wrong; after=0
> Overflow wrong; after=32
> Divbyzero wrong; after=0
> Invalid wrong; after=0
> 32 = FE_INEXACT
> 16 = FE_UNDERFLOW
> 8 = FE_OVERFLOW
> 4 = FE_DIVBYZERO
> 1 = FE_INVALID
>
>
> --
> Summary: Decimal floating-point exception flags done wrong
> Product: gcc
> Version: 4.3.2
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: c
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: tydeman at tybor dot com
> GCC host triplet: 4.3.2
> GCC target triplet: 4.3.2
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bug c/39036] New: Decimal floating-point exception flags done wrong
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
@ 2009-01-30 2:41 ` Andrew Thomas Pinski
2009-01-30 2:41 ` [Bug c/39036] " pinskia at gmail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andrew Thomas Pinski @ 2009-01-30 2:41 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
Sent from my iPhone
On Jan 29, 2009, at 6:00 PM, "tydeman at tybor dot com" <gcc-bugzilla@gcc.gnu.org
> wrote:
> Using gcc 4.3.2-7 on Intel Pentium 4 running Linux Fedora Core 10 and
> -std=gnu99
There were some dfp fixes on the trunk relating to fp exceptions so
you should try the trunk before reporting any more bugs.
>
>
> /* DFP TR 24732 == WG14 / N1176, N1312 */
> #define __STDC_WANT_DEC_FP__ /* Tell implementation that we want
> Decimal FP */
> #pragma STDC FENV_ACCESS ON /* will be testing FP exception
> flags */
>
> #include <stdio.h> /* printf() */
> #include <fenv.h> /* fetestexcept(), FE_* */
> #include <float.h> /* DEC*_MIN, DEC*_MAX */
>
>
> int main(void){
> _Decimal64 d10;
> int before;
> int after;
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = 1.0DD;
> d10 /= 3.0DD;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_INEXACT & after ){
> printf("Inexact raised as expected\n");
> }else{
> printf("Inexact wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = DEC64_MIN;
> d10 *= d10;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_UNDERFLOW & after ){
> printf("Underflow raised as expected\n");
> }else{
> printf("Underflow wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = DEC64_MAX;
> d10 *= d10;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_OVERFLOW & after ){
> printf("Overflow raised as expected\n");
> }else{
> printf("Overflow wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = DEC64_MIN;
> d10 /= (d10-d10);
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_DIVBYZERO & after ){
> printf("Divbyzero raised as expected\n");
> }else{
> printf("Divbyzero wrong; after=%i\n", after);
> }
>
> before = feclearexcept( FE_ALL_EXCEPT );
> d10 = 0.0e-15DD;
> d10 /= d10;
> after = fetestexcept( FE_ALL_EXCEPT );
> if( FE_INVALID & after ){
> printf("Invalid raised as expected\n");
> }else{
> printf("Invalid wrong; after=%i\n", after);
> }
>
> printf("%2i = FE_INEXACT\n", FE_INEXACT);
> printf("%2i = FE_UNDERFLOW\n", FE_UNDERFLOW);
> printf("%2i = FE_OVERFLOW\n", FE_OVERFLOW);
> printf("%2i = FE_DIVBYZERO\n", FE_DIVBYZERO);
> printf("%2i = FE_INVALID\n", FE_INVALID);
>
> return 0;
> }
>
> gets:
>
> Inexact wrong; after=0
> Underflow wrong; after=0
> Overflow wrong; after=32
> Divbyzero wrong; after=0
> Invalid wrong; after=0
> 32 = FE_INEXACT
> 16 = FE_UNDERFLOW
> 8 = FE_OVERFLOW
> 4 = FE_DIVBYZERO
> 1 = FE_INVALID
>
>
> --
> Summary: Decimal floating-point exception flags done wrong
> Product: gcc
> Version: 4.3.2
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: c
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: tydeman at tybor dot com
> GCC host triplet: 4.3.2
> GCC target triplet: 4.3.2
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/39036] Decimal floating-point exception flags done wrong
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
2009-01-30 2:41 ` Andrew Thomas Pinski
2009-01-30 2:41 ` [Bug c/39036] " pinskia at gmail dot com
@ 2009-01-30 7:20 ` rguenth at gcc dot gnu dot org
2009-01-30 21:31 ` janis at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-01-30 7:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2009-01-30 07:19 -------
STDC FENV_ACCESS is not implemented.
*** This bug has been marked as a duplicate of 20785 ***
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/39036] Decimal floating-point exception flags done wrong
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
` (2 preceding siblings ...)
2009-01-30 7:20 ` rguenth at gcc dot gnu dot org
@ 2009-01-30 21:31 ` janis at gcc dot gnu dot org
2009-01-30 22:37 ` kreckel at ginac dot de
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-01-30 21:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from janis at gcc dot gnu dot org 2009-01-30 21:31 -------
The bug is a duplicate of 20785 because the pragma is not implemented.
>From the point of view of GCC it is invalid because <fenv.h> and the functions
it declares are not provided by GCC, but by the C library.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/39036] Decimal floating-point exception flags done wrong
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
` (3 preceding siblings ...)
2009-01-30 21:31 ` janis at gcc dot gnu dot org
@ 2009-01-30 22:37 ` kreckel at ginac dot de
2009-01-30 22:42 ` tydeman at tybor dot com
2009-01-30 23:14 ` joseph at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: kreckel at ginac dot de @ 2009-01-30 22:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from kreckel at ginac dot de 2009-01-30 22:37 -------
(In reply to comment #3)
> From the point of view of GCC it is invalid because <fenv.h> and the functions
> it declares are not provided by GCC, but by the C library.
On the other hand, one can argue that if GCC cannot guarantee that these C
library functions get executed in the proper order, it should provide
replacements of these functions for which it can make this guarantee.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/39036] Decimal floating-point exception flags done wrong
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
` (4 preceding siblings ...)
2009-01-30 22:37 ` kreckel at ginac dot de
@ 2009-01-30 22:42 ` tydeman at tybor dot com
2009-01-30 23:14 ` joseph at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: tydeman at tybor dot com @ 2009-01-30 22:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from tydeman at tybor dot com 2009-01-30 22:42 -------
I consider emulation of decimal FP to be part of the compiler's job. Part of
that emulation is setting the FP execption flags as per IEEE-754-2008.
There is one set of FP exception flags (used for both binary FP and decimal
FP).
Given that the <fenv.h> functions work correctly for binary FP exceptions
(and they mostly do on Intel x86/x87), then they should work correctly for
decimal FP exceptions.
The full set of command line options I give gcc is:
-std=gnu99 -pedantic -H -fno-builtin -frounding-math
My understanding is -frounding-math is supposed to act like a global
#pragma STDC FENV_ACCESS ON
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/39036] Decimal floating-point exception flags done wrong
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
` (5 preceding siblings ...)
2009-01-30 22:42 ` tydeman at tybor dot com
@ 2009-01-30 23:14 ` joseph at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2009-01-30 23:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from joseph at codesourcery dot com 2009-01-30 23:14 -------
Subject: Re: Decimal floating-point exception flags done wrong
On Fri, 30 Jan 2009, tydeman at tybor dot com wrote:
> I consider emulation of decimal FP to be part of the compiler's job. Part of
> that emulation is setting the FP execption flags as per IEEE-754-2008.
The implementation of decimal FP for the GNU system is partly in GCC and
partly in (E)GLIBC (available as patches or an EGLIBC branch). The
implementation approach chosen is that the versions of the
arithmetic/conversion functions that handle exceptions and rounding modes
are included only in the libdfp included with (E)GLIBC, not in libgcc.
(Depending on the target, copies of libm functions to handle exceptions
and rounding modes may need including in libdfp to avoid a dependency on
libm, and this can only be done as part of the libc/libm/libdfp
implementation.)
So, if you want exceptions and rounding modes support for decimal FP, use
an appropriate libc version and link against the associated libdfp.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-01-30 23:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-30 2:00 [Bug c/39036] New: Decimal floating-point exception flags done wrong tydeman at tybor dot com
2009-01-30 2:41 ` Andrew Thomas Pinski
2009-01-30 2:41 ` [Bug c/39036] " pinskia at gmail dot com
2009-01-30 7:20 ` rguenth at gcc dot gnu dot org
2009-01-30 21:31 ` janis at gcc dot gnu dot org
2009-01-30 22:37 ` kreckel at ginac dot de
2009-01-30 22:42 ` tydeman at tybor dot com
2009-01-30 23:14 ` joseph at codesourcery dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).