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/17162] New: warning about invalid precompiled header even if the correct one is used


When using precompiled headers (pch for short) in a way where I can have 
several versions of the same header precompiled with different compiler options
(all pch:s in directory (pch.h.gch for instance), and if I'm using -Winvalid-pch, 
gcc emits a warning for every invalid pch found in the directory
until it gets the right one. It gets pretty annoying when using -Werror. This
shouldn't happen because it finds the correct pch. The warning should be 
shown if gcc doesn't find a valid precompiled header at all.
Here's a test case:

/* test.c */
#include "pch.h"
int main() { return 0; }

/* pch.h empty */

/* Makefile */
all: test1 test2

clean:
        rm -rf *.o test1 test2 pch.h.gch

test1: test.c pch.h.gch/pch.pic
        gcc -H -Winvalid-pch -fpic -o $@ $<
        
test2: test.c pch.h.gch/pch.nonpic
        gcc -H -Winvalid-pch  -o $@ $<

pch.h.gch/pch.pic: pch.h
        mkdir -p pch.h.gch
        gcc -fpic -o $@ $<
        
pch.h.gch/pch.nonpic: pch.h
        mkdir -p pch.h.gch
        gcc -o $@ $<

/* END OF TESTCASE */

When running make, the following is output:

mkdir -p pch.h.gch
gcc -fpic -o pch.h.gch/pch.pic pch.h
gcc -H -Winvalid-pch -fpic -o test1 test.c
! pch.h.gch/pch.pic
mkdir -p pch.h.gch
gcc -o pch.h.gch/pch.nonpic pch.h
gcc -H -Winvalid-pch  -o test2 test.c
test.c:1:17: warning: pch.h.gch/pch.pic: created and used with different settings of -fpic
x pch.h.gch/pch.pic
! pch.h.gch/pch.nonpic

-- 
           Summary: warning about invalid precompiled header even if the
                    correct one is used
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: pch
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rodolfo at rodsoft dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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