Public bug reported:

Source package: gcc-defaults

Problem:

g++ 4.2 and 4.3 does not produce valid precompiled headers.  To
reproduce:

$ g++ --version
g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3

$ cat pch.h
#include <cmath>

$ g++ -c -x c++ -MT pch.h.gch -MD -MP -MF pch.h.dep -o pch.h.gch -O3
-fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -W -Wall
-Werror -Wstrict-aliasing=2 -msse2 pch.h

$ file pch.h.gch
pch.h.gch: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

The above is incorrect; it is almost as though g++ missed the -c option
and tried to link the header file (or something like that?)  Of course,
trying to use this header fails:

$ cat foo.cpp
#include "pch.h"

$ g++ -c -o foo.o -O3 -fno-exceptions -fno-rtti -ffunction-sections 
-fdata-sections -W -Wall -Werror -Wstrict-aliasing=2 -Winvalid-pch -msse2 
foo.cpp
foo.cpp:1:17: error: pch.h.gch: not a PCH file

The above problems also occur with g++-4.2:

$ g++-4.2 --version
g++-4.2 (GCC) 4.2.4 (Ubuntu 4.2.4-5ubuntu1)


However, if I install g++-4.1, everything works as expected:

$ g++-4.1 -c -x c++ -MT pch.h.gch -MD -MP -MF pch.h.dep -o pch.h.gch -O3
-fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -W -Wall
-Werror -Wstrict-aliasing=2 -msse2 pch.h

$ file pch.h.gch
pch.h.gch: GCC precompiled header (version 013) for C++

$ g++-4.1 -c -o foo.o -O3 -fno-exceptions -fno-rtti -ffunction-sections 
-fdata-sections -W -Wall -Werror -Wstrict-aliasing=2 -Winvalid-pch -msse2 
foo.cpp
<no errors>


$ lsb_release -rd
Description:    Ubuntu 9.04
Release:        9.04

$ apt-cache policy g++
g++:
  Installed: 4:4.3.3-1ubuntu1
  Candidate: 4:4.3.3-1ubuntu1
  Version table:
 *** 4:4.3.3-1ubuntu1 0
        500 http://gb.archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status

$ apt-cache policy g++-4.2
g++-4.2:
  Installed: 4.2.4-5ubuntu1
  Candidate: 4.2.4-5ubuntu1
  Version table:
 *** 4.2.4-5ubuntu1 0
        500 http://gb.archive.ubuntu.com jaunty/universe Packages
        100 /var/lib/dpkg/status

$ apt-cache policy g++-4.1
g++-4.1:
  Installed: 4.1.2-24ubuntu1
  Candidate: 4.1.2-24ubuntu1
  Version table:
 *** 4.1.2-24ubuntu1 0
        500 http://gb.archive.ubuntu.com jaunty/universe Packages
        100 /var/lib/dpkg/status

$ uname -s -r -v -m -o
Linux 2.6.28-13-generic #44-Ubuntu SMP Tue Jun 2 07:55:09 UTC 2009 x86_64 
GNU/Linux

** Affects: ubuntu
     Importance: Undecided
         Status: New


** Tags: g++

-- 
g++ does not produce valid precompiled headers
https://bugs.launchpad.net/bugs/394940
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to