Subject: cpp: -iquote behaves wrong but -I- still works correct
Package: cpp
Version: 4:4.0.2-2
Severity: normal

The preprocessor from gcc 4.0.x behaves wrong when using the "-iquote"
option as recommended by a warning when using "-I-".

The problem is that it doesn't honors the include directories specified
with "-iquote" within header files when a file with the same name as the
one to include resists in the same directory as the file currently being
processed.

To make this more clear imagine the following directory layout:

[EMAIL PROTECTED]:~/gcc-test$ find . -type f
./arch/foo.h
./arch/bar.h
./inc/foo.h
./inc/bar.h
./test.c
[EMAIL PROTECTED]:~/gcc-test$


The files have the following contents:

[EMAIL PROTECTED]:~/gcc-test$ cat arch/foo.h
#ifndef foo_h_arch
#define foo_h_arch
#include <bar.h>  // should include inc/bar.h
#endif
[EMAIL PROTECTED]:~/gcc-test$ cat arch/bar.h
#ifndef bar_h_arch
#define bar_h_arch
#endif
[EMAIL PROTECTED]:~/gcc-test$ cat inc/foo.h
#ifndef foo_h
#define foo_h
#include "bar.h"  // should include arch/bar.h
#endif
[EMAIL PROTECTED]:~/gcc-test$ cat inc/bar.h
#ifndef bar_h
#define bar_h
#endif
[EMAIL PROTECTED]:~/gcc-test$ cat test.c
#include <foo.h>  // does it all wrong
#include "foo.h"  // other way works ok
[EMAIL PROTECTED]:~/gcc-test$


Now the output when invoking cpp one time with the old deprecated option
-I- and after that with the recommended -iquote. I used an additional -H
to see which files get processed when:

[EMAIL PROTECTED]:~/gcc-test$ cpp -H -Iarch -I- -Iinc test.c > /dev/null
cc1: note: obsolete option -I- used, please use -iquote instead
. inc/foo.h
.. arch/bar.h
. arch/foo.h
.. inc/bar.h
[EMAIL PROTECTED]:~/gcc-test$ cpp -H -iquote arch -Iinc test.c > /dev/null
. inc/foo.h
.. inc/bar.h
. arch/foo.h
.. inc/bar.h
[EMAIL PROTECTED]:~/gcc-test$


The two commands should be equivalent but aren't. As you can see the
second run does it wrong by including inc/bar.h from within inc/foo.h
and not arch/bar.h as supposed to be. The old syntax does it right by
including arch/bar.h from inc/foo.h since the include directive is made
with quotes not brackets.
The other way (including <..>-headers) from within quoted ".."-headers
works correct for both versions.

I've created a tarball with the above mentioned files for a quick self
test. It's available at [1].

I also took a look at the bug mailing list at gcc.gnu.org but haven't
found this bug there. Maybe I'm the only one using this feature to
separate the order of header file inclusion.


I hope this information helps to get this bug fixed soon.


Yours sincerely,
Mathias Krause

[1] http://www.informatik.tu-cottbus.de/~mkrause/gcc4-iquote-bug.tar.gz

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-mk
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages cpp depends on:
ii  cpp-4.0                       4.0.2-9    The GNU C preprocessor

cpp recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to