floating exception using icc compiler

Posted by Hristo on Stack Overflow See other posts from Stack Overflow or by Hristo
Published on 2010-05-02T04:56:04Z Indexed on 2010/05/02 5:07 UTC
Read the original article Hit count: 347

Filed under:
|
|
|
|

I'm compiling my code via the following command:

icc -ltbb test.cxx -o test

Then when I run the program:

time ./mp6 100 > output.modified
Floating exception
4.871u 0.405s 0:05.28 99.8%     0+0k 0+0io 0pf+0w

I get a "Floating exception". This following is code in C++ that I had before the exception and after:

// before
if (j < E[i]) {
   temp += foo(0, trr[i], ex[i+j*N]);
}

// after
temp += (j < E[i])*foo(0, trr[i], ex[i+j*N]);

This is boolean algebra... so (j < E[i]) is either going to be a 0 or a 1 so the multiplication would result either in 0 or the foo() result. I don't see why this would cause a floating exception. This is what foo() does:

int foo(int s, int t, int e) {
    switch(s % 4) {
        case 0:
            return abs(t - e)/e;
        case 1:
            return (t == e) ? 0 : 1;
        case 2:
            return (t < e) ? 5 : (t - e)/t;
        case 3:
            return abs(t - e)/t;
    }
    return 0;
}

foo() isn't a function I wrote so I'm not too sure as to what it does... but I don't think the problem is with the function foo(). Is there something about boolean algebra that I don't understand or something that works differently in C++ than I know of? Any ideas why this causes an exception?

Thanks, Hristo

© Stack Overflow or respective owner

Related posts about boolean

Related posts about algebra