Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Bug in exp()?

$
0
0

Hello again, 

as my last post went by unnoticed, I chose to restate my question. While analyzing Intel-compiled code, I stumbled upon an interesting code snippet I cannot find another explanation than a potential bug. I wrote the following test program:

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

int main(int argc, char *argv[])
{

   if(argc < 2) {
      printf("argument for exp() is needed\n");
      printf("call %s <the xth power>\n", *argv);
      return EXIT_FAILURE;
   }

   double power = atof(argv[1]);
   double result = exp(power);

   printf("The exponential value of %lf is %lf\n", power, result);

   return EXIT_SUCCESS;
}

The code was compiled with "-O1 -g". Here, we could further pinpoint the original error. The culprit is found in libimf.a. If you extract it, you can find the file exp_wmt.o, having the public function exp.J (exp_J). I'll post again some instructions of the erroneous basic block:

.text:080001C2 jmp     loc_80002EB
.text:080001C7 ; ---------------------------------------------------------------------------
.text:080001C7 cmp     ecx, 80000000h <-- never executed
.text:080001CD jb      short loc_80001F2
.text:080001CF cmp     ecx, 0C086232Bh

 

As the code resides in a static library, I doubt it is subject to further compiler optimizations. I think this is a bug.

Thanks for your help, 

Sebastian


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>