https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66246
Bug ID: 66246 Summary: PCH breaks preprocessor Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: kai-bugs at cats dot ms Target Milestone: --- Created attachment 35590 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35590&action=edit Header Test consists of: - make sure we have no PCH - compile the source w/o PCH - compile the PCH - compile the source w/PCH As far as I can tell, the reason for the problems is that macros no longer get expanded If it matters, this is from the MinGW packaged with Qt 5.4. $ cat t.sh #! /bin/bash -x gcc --version rm th.hh.gch g++ -Winvalid-pch -c -save-temps test.cc g++ -x c++-header -c -save-temps th.hh g++ -Winvalid-pch -c -save-temps test.cc $ ./t.sh + gcc --version gcc.exe (i686-posix-dwarf-rev2, Built by MinGW-W64 project) 4.9.1 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + rm th.hh.gch + g++ -Winvalid-pch -c -save-temps test.cc + g++ -x c++-header -c -save-temps th.hh + g++ -Winvalid-pch -c -save-temps test.cc In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:13:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw_secapi.h:51:10: error: redefinition of 'struct __if_array<true, __dsttype>' struct __if_array <true, __dsttype> { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:13:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw_secapi.h:51:10: error: previous definition of 'struct __if_array<true, __dsttype>' struct __if_array <true, __dsttype> { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h: In function 'void __debugbreak()': C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:657:101: error: redefinition of 'void __debugbreak()' __MINGW_INTRIN_INLINE void __cdecl __debugbreak(void) ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:657:101: note: 'void __debugbreak()' previously defined here __MINGW_INTRIN_INLINE void __cdecl __debugbreak(void) ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h: At global scope: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:159:16: error: redefinition of 'struct localeinfo_struct' typedef struct localeinfo_struct { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:159:16: error: previous definition of 'struct localeinfo_struct' typedef struct localeinfo_struct { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:18: error: invalid type in declaration before ',' token } _locale_tstruct,*_locale_t; ^ C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:18: error: conflicting declaration 'typedef int _locale_tstruct' In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:3: note: previous declaration as 'typedef struct localeinfo_struct _locale_tstruct' } _locale_tstruct,*_locale_t; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:20: error: conflicting declaration 'typedef int* _locale_t' } _locale_tstruct,*_locale_t; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:20: note: previous declaration as 'typedef struct localeinfo_struct* _locale_t' } _locale_tstruct,*_locale_t; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:166:16: error: redefinition of 'struct tagLC_ID' typedef struct tagLC_ID { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:166:16: error: previous definition of 'struct tagLC_ID' typedef struct tagLC_ID { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:8: error: invalid type in declaration before ',' token } LC_ID,*LPLC_ID; ^ C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:8: error: conflicting declaration 'typedef int LC_ID' In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:3: note: previous declaration as 'typedef struct tagLC_ID LC_ID' } LC_ID,*LPLC_ID; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:10: error: conflicting declaration 'typedef int* LPLC_ID' } LC_ID,*LPLC_ID; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:10: note: previous declaration as 'typedef struct tagLC_ID* LPLC_ID' } LC_ID,*LPLC_ID; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:175:16: error: redefinition of 'struct threadlocaleinfostruct' typedef struct threadlocaleinfostruct { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:175:16: error: previous definition of 'struct threadlocaleinfostruct' typedef struct threadlocaleinfostruct { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:199:16: error: invalid type in declaration before ';' token } threadlocinfo; ^ C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:199:16: error: conflicting declaration 'typedef int threadlocinfo' In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:199:3: note: previous declaration as 'typedef struct threadlocaleinfostruct threadlocinfo' } threadlocinfo; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:50:18: error: redefinition of 'struct _div_t' typedef struct _div_t { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:50:18: error: previous definition of 'struct _div_t' typedef struct _div_t { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:53:10: error: invalid type in declaration before ';' token } div_t; ^ C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:53:10: error: conflicting declaration 'typedef int div_t' In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:53:5: note: previous declaration as 'typedef struct _div_t div_t' } div_t; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:55:18: error: redefinition of 'struct _ldiv_t' typedef struct _ldiv_t { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:55:18: error: previous definition of 'struct _ldiv_t' typedef struct _ldiv_t { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:58:11: error: invalid type in declaration before ';' token } ldiv_t; ^ C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:58:11: error: conflicting declaration 'typedef int ldiv_t' In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:58:5: note: previous declaration as 'typedef struct _ldiv_t ldiv_t' } ldiv_t; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:67:5: error: conflicting declaration 'typedef struct _LDOUBLE _LDOUBLE' } _LDOUBLE; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:67:5: note: previous declaration as 'typedef struct _LDOUBLE _LDOUBLE' } _LDOUBLE; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:74:5: error: conflicting declaration 'typedef struct _CRT_DOUBLE _CRT_DOUBLE' } _CRT_DOUBLE; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:74:5: note: previous declaration as 'typedef struct _CRT_DOUBLE _CRT_DOUBLE' } _CRT_DOUBLE; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:78:5: error: conflicting declaration 'typedef struct _CRT_FLOAT _CRT_FLOAT' } _CRT_FLOAT; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:78:5: note: previous declaration as 'typedef struct _CRT_FLOAT _CRT_FLOAT' } _CRT_FLOAT; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:85:5: error: conflicting declaration 'typedef struct _LONGDOUBLE _LONGDOUBLE' } _LONGDOUBLE; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:85:5: note: previous declaration as 'typedef struct _LONGDOUBLE _LONGDOUBLE' } _LONGDOUBLE; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:92:5: error: conflicting declaration 'typedef struct _LDBL12 _LDBL12' } _LDBL12; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:92:5: note: previous declaration as 'typedef struct _LDBL12 _LDBL12' } _LDBL12; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h: In function 'long long int _abs64(long long int)': C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:335:108: error: redefinition of 'long long int _abs64(long long int)' __MINGW_INTRIN_INLINE __int64 __cdecl _abs64(__int64 x) { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:335:108: note: 'long long int _abs64(long long int)' previously defined here __MINGW_INTRIN_INLINE __int64 __cdecl _abs64(__int64 x) { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h: At global scope: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:626:57: error: conflicting declaration 'typedef struct lldiv_t lldiv_t' typedef struct { __MINGW_EXTENSION long long quot, rem; } lldiv_t; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:626:57: note: previous declaration as 'typedef struct lldiv_t lldiv_t' typedef struct { __MINGW_EXTENSION long long quot, rem; } lldiv_t; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:49:149: error: redefinition of 'template<unsigned int __drive_size, unsigned int __dir_size, unsigned int __name_size, unsigned int __ext_size> errno_t _splitpath_s(const char*, char (&)[__drive_size], char (&)[__dir_size], char (&)[__name_size], char (&)[__ext_size])' __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_splitpath_s,char,_Dest) ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:49:149: note: 'template<unsigned int __drive_size, unsigned int __dir_size, unsigned int __name_size, unsigned int __ext_size> errno_t _splitpath_s(const char*, char (&)[__drive_size], char (&)[__dir_size], char (&)[__name_size], char (&)[__ext_size])' previously declared here __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_splitpath_s,char,_Dest) ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:58:149: error: redefinition of 'template<unsigned int __drive_size, unsigned int __dir_size, unsigned int __name_size, unsigned int __ext_size> errno_t _wsplitpath_s(const wchar_t*, wchar_t (&)[__drive_size], wchar_t (&)[__dir_size], wchar_t (&)[__name_size], wchar_t (&)[__ext_size])' __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_wsplitpath_s,wchar_t,_Dest) ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:58:149: note: 'template<unsigned int __drive_size, unsigned int __dir_size, unsigned int __name_size, unsigned int __ext_size> errno_t _wsplitpath_s(const wchar_t*, wchar_t (&)[__drive_size], wchar_t (&)[__dir_size], wchar_t (&)[__name_size], wchar_t (&)[__ext_size])' previously declared here __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_wsplitpath_s,wchar_t,_Dest) ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:46:18: error: redefinition of 'struct _heapinfo' typedef struct _heapinfo { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:46:18: error: previous definition of 'struct _heapinfo' typedef struct _heapinfo { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:50:14: error: invalid type in declaration before ';' token } _HEAPINFO; ^ C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:50:14: error: conflicting declaration 'typedef int _HEAPINFO' In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:50:5: note: previous declaration as 'typedef struct _heapinfo _HEAPINFO' } _HEAPINFO; ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h: In function 'void* _MarkAllocaS(void*, unsigned int)': C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:144:25: error: redefinition of 'void* _MarkAllocaS(void*, unsigned int)' static __inline void *_MarkAllocaS(void *_Ptr,unsigned int _Marker) { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:144:25: note: 'void* _MarkAllocaS(void*, unsigned int)' previously defined here static __inline void *_MarkAllocaS(void *_Ptr,unsigned int _Marker) { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from test.cc:4: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h: In function 'void _freea(void*)': C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:163:51: error: redefinition of 'void _freea(void*)' static __inline void __cdecl _freea(void *_Memory) { ^ In file included from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0, from C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17, from th.hh:1: C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:163:51: note: 'void _freea(void*)' previously defined here static __inline void __cdecl _freea(void *_Memory) { ^ test.cc: In function 'void f()': test.cc:14:8: error: '__FILE__' was not declared in this scope bla(); ^ test.cc:14:18: error: '__LINE__' was not declared in this scope bla(); ^