public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/30380]  New: bug in cppdefault.c
@ 2007-01-05  3:54 hartmann at physik dot uni-kl dot de
  2007-01-05  4:25 ` [Bug c/30380] " pinskia at gcc dot gnu dot org
  2007-01-05 16:42 ` hartmann at physik dot uni-kl dot de
  0 siblings, 2 replies; 3+ messages in thread
From: hartmann at physik dot uni-kl dot de @ 2007-01-05  3:54 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-05 16:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-05  3:54 [Bug c/30380] New: bug in cppdefault.c hartmann at physik dot uni-kl dot de
2007-01-05  4:25 ` [Bug c/30380] " pinskia at gcc dot gnu dot org
2007-01-05 16:42 ` hartmann at physik dot uni-kl dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).