[Bug c/30380] New: bug in cppdefault.c
hartmann at physik dot uni-kl dot de
gcc-bugzilla@gcc.gnu.org
Fri Jan 5 03:54:00 GMT 2007
hello!
there is a nasty little bug in cppdefault.c in gcc 4.0.3:
wrong:
const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
correct:
const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 1;
it is also persistent in gcc-4.1.1
effects of this bug:
add_standard_paths in c-incpath.c is defeated. therefore standard include
headers
are not accessed relatively to the executable-path. instead there are
accessed
with the paths which are build in during configuration. this does not matter
if
you want to use gcc only in /usr. but if the prefix-dir and the installdir
differ
you get a problem. this is common on mingw.
When GCC_INCLUDE_DIR is shorter than 8 chars you get an even bigger problem
because
size_t wraps around...
in case anybody is interested:
i stumbled over this bug by trying to build a position-independent gcc for
mingw.
to do this, i must hack cppdefault.c:
#define GCC_INCLUDE_DIR "/usr/lib/gcc/mingw32/4.0.3/"
#define GPLUSPLUS_INCLUDE_DIR
"/usr/lib/gcc/mingw32/4.0.3/../../../../include/c++/4.0.3"
#define GPLUSPLUS_TOOL_INCLUDE_DIR
"/usr/lib/gcc/mingw32/4.0.3/../../../../include/c++/4.0.3/mingw32"
#define GPLUSPLUS_BACKWARD_INCLUDE_DIR
"/usr/lib/gcc/mingw32/4.0.3/../../../../include/c++/4.0.3/backward"
#define LOCAL_INCLUDE_DIR "/usr/lib/gcc/mingw32/4.0.3/include"
#undef PREFIX_INCLUDE_DIR
#undef CROSS_INCLUDE_DIR
#undef TOOL_INCLUDE_DIR
#undef SYSTEM_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR
"/usr/lib/gcc/mingw32/4.0.3/../../../../include"
here /usr/lib/gcc/mingw32/4.0.3/ is a dummy which could be anything... . it
is replaced
later by add_standard_paths. perhaps there is a way to avoide this hack
(exec-prefix ??) but i have not tried this jet.
greetings, timo
--
Summary: bug in cppdefault.c
Product: gcc
Version: 4.0.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hartmann at physik dot uni-kl dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30380
More information about the Gcc-bugs
mailing list