Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 8657 - g++ -O -I/usr/include: Fails if #include <math.h>
Summary: g++ -O -I/usr/include: Fails if #include <math.h>
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GCC Porting (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Matthew Kennedy (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-02 14:34 UTC by Ferris McCormick (RETIRED)
Modified: 2003-01-28 00:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ferris McCormick (RETIRED) gentoo-dev 2002-10-02 14:34:10 UTC
Suppose your source c++ program is the one line

#include <maht.h>

and you compile it with "g++ -O -I/usr/include

Then, you get the following failure:
cc1plus: warning: changing search order for system directory "/usr/include"
cc1plus: warning:   as it has already been specified as a non-system directory
In file included from /usr/include/math.h:350,
                 from c.cc:1:
/usr/include/bits/mathinline.h:216: declaration of `double fdim(double, double)
   ' throws different exceptions
/usr/include/bits/mathcalls.h:313: than previous declaration `double 
   fdim(double, double) throw ()'
/usr/include/bits/mathinline.h:223: declaration of `float fdimf(float, float)' 
   throws different exceptions
/usr/include/bits/mathcalls.h:313: than previous declaration `float 
   fdimf(float, float) throw ()'

The work-around is easy in principle:  don't "-I/usr/include"
This gets painful, however, with a product like omniORB (free CORBA) which
has lots of little included makefile sources all of which have lines like
CXXFLAGS += -I$(PYPREFIX)/include
(And the python directory is supplied from asking python:
PYPREFIX  := $(shell $(PYTHON) -c 'import sys; print sys.exec_prefix')

An unacceptable fix is to specify -O0;
A terrible solution is to put #include <cmath> in front of the
#include <math.h>
Comment 1 Matthew Kennedy (RETIRED) gentoo-dev 2002-10-21 02:54:27 UTC
yep. i fix packages nearly every day which included -I/usr/include. 
-I/usr/include is wrong and must be changed (see gcc-dev for the reasons). 
standard procedure is to fix the build system not to -I/usr/include and then 
send the patch upstream.