C++: inlining issues

Martin Reinecke martin@MPA-Garching.MPG.DE
Fri Dec 10 03:18:00 GMT 1999


>  I fixed the bug you reported in my last checkin.  Thanks!

Good job! My application runs considerably faster now.

However, I still get "can't inline" warnings in several places.
Here is one example:

#include <cmath>

int main()
{
  double foo = 4.5;
  if (abs (0.5-abs (foo-0.5)) < 1e-10) foo+=1;
}

~/temp>/afs/mpa/data/martin/egcscvs/bin/g++ --save-temps -O2 -Winline test.cxx -v -c
Reading specs from /afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 19991210 (experimental)
 /afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=96 -D__cplusplus -D__ELF__ -Dunix -D__i386__
-Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -D__OPTIMIZE__ -Winline -Acpu(i386) -Amachine(i386) -Di386 -D__i386
-D__i386__ -D__tune_pentiumpro__ test.cxx test.ii
GNU CPP version 2.96 19991210 (experimental) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/../../../../include/g++-3
 /afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/../../../../i686-pc-linux-gnu/include
 /afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/local/include
End of omitted list.
 /afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/cc1plus test.ii -quiet -dumpbase test.cc -O2 -Winline -version -o test.s
GNU C++ version 2.96 19991210 (experimental) (i686-pc-linux-gnu) compiled by GNU C version 2.96 19991210 (experimental).
/afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/../../../../include/g++-3/cmath: In function `int main ()':
/afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/../../../../include/g++-3/cmath:42: warning: can't inline call to `double abs (double)'
/afs/mpa/data/martin/egcscvs/lib/gcc-lib/i686-pc-linux-gnu/2.96/../../../../include/g++-3/cmath:7: warning: called from here
 as -V -Qy -o test.o test.s
GNU assembler version 2.9.5 (i386-linux) using BFD version 2.9.5.0.14

First: The compiler issues a warning for function main() in <cmath>; something seems to go wrong here
Second: There should be no problem to inline the function double abs(double), since it is only a wrapper
for fabs().

Another thing: I noticed erroneous warnings like "control reaches end of non-void function" for functions
where the last stamement was "return <something>;". The number of these warnings seems to increase
(1 warning sometime last week; about 10 for today's snapshot) for my application. I already submitted a bug report
for this problem. Can this have anything to do with the new inliner?

Martin
test.ii.gz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ii.gz
Type: application/x-gzip
Size: 6797 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19991210/22b0b546/attachment.bin>


More information about the Gcc-bugs mailing list