Bug 18567 - Wrong "-O" description in manual ?
Summary: Wrong "-O" description in manual ?
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-19 15:29 UTC by benoit.sibaud
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description benoit.sibaud 2004-11-19 15:29:25 UTC
8<------------
#include <iostream>

double foo(unsigned nb) {
  /* volatile */ double sum = 0.9;
  for (unsigned i=0; i<nb;++i) sum+=0.1;
  return sum;
}

int main() {
  double old = 1.0;
  double diff = old - foo(1);
  std::cout << diff << std::endl;
}
8<------------

g++-3.3.4 foo.cpp
RESULT 0
g++-3.3.4 -O foo.cpp
RESULT -2.77556e-17
http://gcc.gnu.org/onlinedocs/gcc-3.3.4/gcc/Optimize-Options.html#Optimize%20Options
(-O equivalent to 10 or 11 options)
g++-3.3.4 -fdefer-pop -fmerge-constants -fthread-jumps -floop-optimize
-fcrossjumping -fif-conversion -fif-conversion2 -fdelayed-branch
-fguess-branch-probability -fcprop-registers (-fomit-frame-pointer) foo.cpp
RESULT 0

g++-3.4.2 foo.cpp
RESULT 0
g++-3.4.2 -O foo.cpp
RESULT -2.77556e-17
http://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Optimize-Options.html#Optimize-Options
(-O equivalent to 9 or 10 options)
g++-3.4 -fdefer-pop -fmerge-constants -fthread-jumps -floop-optimize 
-fif-conversion -fif-conversion2 -fdelayed-branch -fguess-branch-probability
-fcprop-registers (-fomit-frame-pointer) foo.cpp
RESULT 0

With volatile "sum" or -ffloat-store, RESULT 0.
Comment 1 Andrew Pinski 2004-11-19 15:32:38 UTC
This is a dup of 323.  Also -O enables more than what can be enabled with flags.

*** This bug has been marked as a duplicate of 323 ***
Comment 2 Andrew Pinski 2004-11-19 15:33:08 UTC
This is a dup of 323.  Also -O enables more than what can be enabled with flags.
"Not all optimizations are controlled directly by a flag. Only optimizations that have a flag are listed."

*** This bug has been marked as a duplicate of 323 ***

*** This bug has been marked as a duplicate of 323 ***