Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is -freciprocal-math unsafe in GCC?

-freciprocal-math in GCC changes the following code

double a = b / c;

to

 double tmp = 1/c;
 double a = b * tmp;

In GCC manual, it's said that such an optimization is unsafe and is not sticked to IEEE standards. But I cannot think of an example. Could you give an example about this?

like image 631
Kid Avatar asked May 21 '12 03:05

Kid


People also ask

Why is get unsafe in C?

However, gets() is inherently unsafe, because it copies all input from STDIN to the buffer without checking size. This allows the user to provide a string that is larger than the buffer size, resulting in an overflow condition.

What are GCC warnings?

Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there may have been an error. The following language-independent options do not enable specific warnings but control the kinds of diagnostics produced by GCC.

Is GCC good for C?

Though there are many compilers available for C, GCC stands out to be one of the best as of now. The winner declaration here lies based on durability, optimization, speed, and code/error/syntax checks. Through this, we can clearly understand that the Compiler is an important pillar to the programming languages.

Why do we use GCC?

GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language. It can also be used to compile Objective C and Objective C++.


1 Answers

Dividing by 10 and multiplying by 0.1000000000000000055511151231257827021181583404541015625 are not the same thing.

like image 125
R.. GitHub STOP HELPING ICE Avatar answered Sep 22 '22 17:09

R.. GitHub STOP HELPING ICE