Bug 71090 - #include <cmath> cannot locate math.h
Summary: #include <cmath> cannot locate math.h
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 6.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-12 19:45 UTC by Tommy McGuire
Modified: 2017-01-29 01:28 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Simple source file (60 bytes, text/x-csrc)
2016-05-12 19:45 UTC, Tommy McGuire
Details
Preprocessed source file (1.56 KB, text/plain)
2016-05-12 19:46 UTC, Tommy McGuire
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tommy McGuire 2016-05-12 19:45:04 UTC
Created attachment 38478 [details]
Simple source file

Using the gcc 6.1.1-1 package from Arch Linux, the attached program math.cc fails to compile with the following error when compiled with the given command line:

$ gcc -v --save-temps -o math math.cc -isystem /usr/include
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 6.1.1 20160501 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'math' '-isystem' '/usr/include' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/cc1plus -E -quiet -v -D_GNU_SOURCE -isystem /usr/include math.cc -mtune=generic -march=x86-64 -fpch-preprocess -o math.ii
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include-fixed
End of search list.
In file included from math.cc:1:0:
/usr/include/c++/6.1.1/cmath:45:23: fatal error: math.h: No such file or directory
 #include_next <math.h>
                       ^
compilation terminated. 

The original problem was discovered while compiling the Pony language compiler, which uses LLVM and uses -isystem to put the location of the LLVM headers at the start of the bracket search path.
Comment 1 Tommy McGuire 2016-05-12 19:46:01 UTC
This may be related to Bug #70936 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936).
Comment 2 Tommy McGuire 2016-05-12 19:46:41 UTC
Created attachment 38479 [details]
Preprocessed source file
Comment 3 Tommy McGuire 2016-05-12 19:57:41 UTC
Pony bug 797: https://github.com/ponylang/ponyc/issues/797
Comment 4 Andrew Pinski 2016-05-12 20:22:33 UTC
This is not a GCC bug you are changing the search directory paths what do you expect to happen?

Note Mozilla had a similar bug which is being fixed there.
Comment 5 bastl73 2017-01-28 22:01:00 UTC
I had the same error with gcc-6.3 and it seems to be

#include_next <whatever.h>   fails

#include <whatever.h>   works
Comment 6 Jonathan Wakely 2017-01-29 01:28:58 UTC
If you mess with the order of system header directories then you mess up how headers are found. So don't do that.