Testcase: void f(float); void g(double x) { f(-x); } Using -fdump-tree-original shows that GCC understands the above code as "f(-(float)x)", although it should really be "f((float)(-x))". As a consequence, the generated code is not efficient (on x86), as GCC will have to store x to memory as a float before loading it again and changing its sign. Moreover, the computed value is not the expected one when the rounding mode is a directed rounding, as the conversion happens before the sign change.
Tested with Debian GCC 3.3.6, 3.4.6, 4.0.4, and 4.1.2. Version 3.3 generates the correct code, the other ones don't. -- Summary: Incorrect interpretation of floating-point unary minus Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: guillaume dot melquiond at ens-lyon dot fr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29538