Past overflow discussion

F

Frank

Consult gcc's documentation:

Thx, Keith, I wouldn't have found that in a million years. What is
the newsgroup that deals with gcc-specific stuff?
   * `The default state for the `FENV_ACCESS' pragma (C99 7.6.1).'

     This pragma is not implemented, but the default is to "off" unless
     `-frounding-math' is used in which case it is "on".

For whatever I tested with, it made no difference in the output
whether that flag was included.
gcc does not fully conform to C99.

What's more, it doesn't support annex f completely, which is, of
course, their prerogative. I've been dinking around with this:

F:\gfortran\dan>gcc iec3.c -Wall -Wextra -o iec.exe

F:\gfortran\dan>iec
-1.#IND00 1.#QNAN0 -1.#IND00 -1.#IND00
1.#INF00 1.#INF00 1.#INF00
1100000000000000100000000000000000000000000000000000000000000000000000000000.000
000
1.#INF00
-0.000000
erfc is 2.000000
tgamma is 1.#INF00
tgamma is 1.#INF00

F:\gfortran\dan>type iec3.c

#include <stdio.h>
#include <fenv.h>
#include <math.h>

int main(void)
{
float f[] = { 0.0/0.0 }; // raises an exception
static float x = 0.0/0.0; // does not raise an exception
float y = 0.0/0.0; // raises an exception
double z = 0.0/0.0; // raises an exception

printf("%f %f %f %f\n",f[0], x, y ,z);


float u[] = { 1.1e75 }; // raises exceptions
static float v = 1.1e75; // does not raise exceptions
float w = 1.1e75; // raises exceptions
double a = 1.1e75; // may raise exceptions
float b = 1.1e75f; // may raise exceptions
long double c = 1.1e75; // does not raise exceptions

printf("%f %f %f \n%f \n %f \n %Lf\n", u[0],v,w,a,b,c);

float g = erfc(-u[0]);
printf("erfc is %f\n", g);

float h = tgamma(0.0);
printf("tgamma is %f\n", h);
h = tgamma(-3);
printf("tgamma is %f\n", h);
return 0;
}


// gcc iec3.c -Wall -Wextra -o iec.exe


F:\gfortran\dan>

This shows that the static storage class specifier doesn't make a
difference in not raising an exception. I would have expected
differing exceptions for the tgamma's.

However, erfc(-¥) returns 2.
 
K

Keith Thompson

Frank said:
Thx, Keith, I wouldn't have found that in a million years. What is
the newsgroup that deals with gcc-specific stuff?

gnu.gcc.help

I found that particular passage by typing "info gcc" and searching for
FENV_ACCESS.

[...]
 
D

Dik T. Winter

> Other answers were similar, specially from the representative of
> the committee, Mr Gwyn: ....
> Great answers aren't they?

Yes, they tell you specifically that the useability is limited.
> *Five years* later there isn't any reaction of the committee, and no
> work in this is being done at all.

Well, why should they work on something that they do not think useful?
Anyhow, I also fail to see the advantage, unless the "overflow flag"
is sticky. That is that after:
x = a * b + c;
a check for overflow will reveal whether any of the two operations (or
both) did overflow. Your specifiction is not good enough to tell
what happens if the multiplication overflows but the subsequent
addition not.
 
D

Dik T. Winter

>
> I'm surprised that IEEE stuff doesn't cover this for C. It does for
> fortran. I notice in H&S V a single reference to IEEE, on p 135: IEEE
> support in C is optional.

IEEE doesn't cover it for Fortran either, I think, because IEEE is for
floating-point, and here the issue is integer overflow.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top