This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug pch/13218] New: Potential problems with PCH and includes relative to current directory


There is a potential problem with PCH
when the PCH header file includes other
header files without using absolute paths
(and nobody uses absolute paths, so you
might as well say: when including other
header files), in combination with search
paths for header files that are relative
to the current directory (i.e. -I. -I..)

Namely, when there exist two or more such
header files with the same name, then gcc
does not see that in fact a *different*
headerfile is being included then what
the pch was compiled with.

HOW TO REPEAT

I attached a tar ball that will allow you
reproduce the following example.

Please edit Makefile first and adjust the
value of CC first!

~/c++/tests/pch>make
make[1]: Entering directory `/home/carlo/c++/tests/pch'
make[2]: Entering directory `/home/carlo/c++/tests/pch/a'
rm -f a.out ../include/pch.h.gch
make[2]: Leaving directory `/home/carlo/c++/tests/pch/a'
make[2]: Entering directory `/home/carlo/c++/tests/pch/b'
rm -f a.out ../include/pch.h.gch
make[2]: Leaving directory `/home/carlo/c++/tests/pch/b'
make[1]: Leaving directory `/home/carlo/c++/tests/pch'

First we show how it works WITHOUT pch:
make[1]: Entering directory `/home/carlo/c++/tests/pch/a'
gcc-cvs-3.4 -I. -I../include -W -Wall -pedantic -Winvalid-pch a.c
make[1]: Leaving directory `/home/carlo/c++/tests/pch/a'
Running program a...
Program 'a': Sorry, not enough authorisation.
make[1]: Entering directory `/home/carlo/c++/tests/pch/b'
gcc-cvs-3.4 -I. -I../include -W -Wall -pedantic -Winvalid-pch b.c
make[1]: Leaving directory `/home/carlo/c++/tests/pch/b'
Running program b...
Program 'b': Innocent little program.

Next we show what happens WITH pch:
make[1]: Entering directory `/home/carlo/c++/tests/pch/a'
rm -f ../include/pch.h.gch      # Work around PR12606
gcc-cvs-3.4 -I. -I../include -W -Wall -pedantic -Winvalid-pch -c -o
../include/pch.h.gch ../include/pch.h
gcc-cvs-3.4 -I. -I../include -W -Wall -pedantic -Winvalid-pch a.c
make[1]: Leaving directory `/home/carlo/c++/tests/pch/a'
Running program a...
Program 'a': Sorry, not enough authorisation.
make[1]: Entering directory `/home/carlo/c++/tests/pch/b'
gcc-cvs-3.4 -I. -I../include -W -Wall -pedantic -Winvalid-pch b.c
make[1]: Leaving directory `/home/carlo/c++/tests/pch/b'
Running program b...
Program 'b': Commencing world destruction...

-- 
           Summary: Potential problems with PCH and includes relative to
                    current directory
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: pch
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carlo at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13218


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]