[wwwdocs] gcc-4.7/porting_to.html
As requested by Jakub. I thought it better to get this in, warts and all, and have it be corrected than to dally around again and have it not checked in. -benjamin2012-01-11 Benjamin Kosnik * htdocs/gcc-4.7/porting_to.html: Add. Index: htdocs/gcc-4.7/porting_to.html === RCS file: htdocs/gcc-4.7/porting_to.html diff -N htdocs/gcc-4.7/porting_to.html *** /dev/null 1 Jan 1970 00:00:00 - --- htdocs/gcc-4.7/porting_to.html 12 Jan 2012 00:06:17 - *** *** 0 --- 1,266 + + + + Porting to GCC 4.7 + + + + Porting to GCC 4.7 + + + The GCC 4.7 release series differs from previous GCC releases in more + than the usual list of + http://gcc.gnu.org/gcc-4.7/changes.html";>changes. Some of + these are a result of bug fixing, and some old behaviors have been + intentionally changed in order to support new standards, or relaxed + in standards-conforming ways to facilitate compilation or runtime + performance. Some of these changes are not visible to the naked eye + and will not cause problems when updating from older versions. + + + + However, some of these changes are visible, and can cause grief to + users porting to GCC 4.7. This document is an effort to identify major + issues and provide clear solutions in a quick and easily searched + manner. Additions and suggestions for improvement are welcome. + + + General issues + + Use of invalid flags when linking + + + Earlier releases did not warn or error about completely invalid + options on gcc/g++/gfortran etc. command lines, if nothing was + compiled, but only linking was performed. This is no longer the + case. For example, + + + + gcc -Wl -o foo foo.o -mflat_namespace + + + + Now produces the following error + + + + error: unrecognized command line option â-Wlâ + error: unrecognized command line option â-mflat_namespaceâ + + + + Invalid options need to be removed from the command line or replaced + by something that is valid. + + + C language issues + + Boolean type promotion changes + + + The C compiler no longer promotes boolean values in arithmetic + statements to integer values. Configure-related code that checks for + C99'smay be impacted. If the following line is + newly present in configure logs, then support is + incorrectly configured. + + + + checking for stdbool.h that conforms to C99... no + + + + C++ language issues + + Header dependency changes + + + Many of the standard C++ library include files have been edited to no + longer include to remove http://gcc.gnu.org/PR49745";>namespace pollution. + + + + As such, C++ programs that used functions + including truncate, sleep + or pipe without first including will no + longer compile. The diagnostic produced is similar to: + + + + error: âtruncateâ was not declared in this scope + + + + error: âsleepâ was not declared in this scope + + + + error: âpipeâ was not declared in this scope + + + + error: there are no arguments to 'offsetof' that depend on a template + parameter, so a declaration of 'offsetof' must be available + + + + Fixing this issue is easy: just include . + + + Note on proper checking for thread support + + + At no time, should user-level code use private + GCC-implementation-space macros such as + _GLIBCXX_HAS_GTHREADS to determine at compile-time + concurrency support. Instead, use the POSIX + macro _REENTRANT. + + + Name lookup changes + + + The C++ compiler no longer performs an extra unqualified lookups that + had performed in the past, namely http://gcc.gnu.org/PR24163";>dependant base class scope lookups and + http://gcc.gnu.org/PR29131";>unqualified template function + lookups. + + + + C++ programs that depended on the compiler's previous behavior may + longer compile. For example, code such as + + + + template + int t(T i) + { return f(i); } + + int + f(int i) + { return i; } + + int + main() + { + return t(1); + } + + + + + Will result in the following diagnostic: + + + In instantiation of âint t(T) [with T = int]â: + required from here + error: âfâ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] + note: âint f(int)â declared here, later in the translation unit + + + + To fix, make sure the function f in the code above is + declared before first use in function t. Like so: + + + + int + f(int i) + { return i; } + + template + int t(T i) + { return f(i); } + + int + main() + { + return t(1); + } + + + + This can be temporarily worked around by using -fpermissive. + + + Detection of redeclared variable names in nested scopes + + + The C++ compiler no longer allows identical identifiers in some http://gcc.gnu.org/PR2288";>nested scopes. Namely: + + + + void f(int); + + int main() + { + fo
Re: [wwwdocs] gcc-4.7/porting_to.html
validation fixups... -benjamin2012-01-11 Benjamin Kosnik * htdocs/gcc-4.7/porting_to.html: Fixup for validation. Index: htdocs/gcc-4.7/porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/porting_to.html,v retrieving revision 1.1 diff -c -p -r1.1 porting_to.html *** htdocs/gcc-4.7/porting_to.html 12 Jan 2012 00:08:30 - 1.1 --- htdocs/gcc-4.7/porting_to.html 12 Jan 2012 01:09:24 - *** longer compile. For example, code such a *** 133,139 ! template int t(T i) { return f(i); } --- 133,139 ! templateint t(T i) { return f(i); } *** int *** 169,175 f(int i) { return i; } ! template int t(T i) { return f(i); } --- 169,175 f(int i) { return i; } ! template int t(T i) { return f(i); }
Re: [wwwdocs] gcc-4.7/porting_to.html
> validation fixups... More of them -benjamin2012-01-11 Benjamin Kosnik * htdocs/gcc-4.7/porting_to.html: Fixup for validation. Index: htdocs/gcc-4.7/porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/porting_to.html,v retrieving revision 1.2 diff -c -r1.2 porting_to.html *** htdocs/gcc-4.7/porting_to.html 12 Jan 2012 01:11:40 - 1.2 --- htdocs/gcc-4.7/porting_to.html 12 Jan 2012 02:51:05 - *** *** 45,52 ! error: unrecognized command line option â-Wlâ ! error: unrecognized command line option â-mflat_namespaceâ --- 45,52 ! error: unrecognized command line option ‘-Wl’ ! error: unrecognized command line option ‘-mflat_namespace’ *** *** 88,102 ! error: âtruncateâ was not declared in this scope ! error: âsleepâ was not declared in this scope ! error: âpipeâ was not declared in this scope --- 88,102 ! error: ‘truncate’ was not declared in this scope ! error: ‘sleep’ was not declared in this scope ! error: ‘pipe’ was not declared in this scope *** *** 153,162 Will result in the following diagnostic: ! In instantiation of âint t(T) [with T = int]â: required from here ! error: âfâ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] ! note: âint f(int)â declared here, later in the translation unit --- 153,162 Will result in the following diagnostic: ! In instantiation of ‘int t(T) [with T = int]’ required from here ! error: ‘f’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] ! note: ‘int f(int)’ declared here, later in the translation unit *** *** 209,216 ! error: redeclaration of âint iâ ! error: âint iâ previously declared here --- 209,216 ! error: redeclaration of ‘int i’ ! error: ‘int i’ previously declared here *** *** 221,244 User-defined literals and whitespace ! The C++ compiler in ISO C11 mode -std={c++11,c++0x,gnu++11,gnu++0x} supports user defined literals, which are incompatible with some valid ISO C++03 code. ! In particular, whitespace is now needed after a string literal and before something that could be a valid user defined literal. Take the valid ISO C++03 code ! const char *p = "foobar"__TIME__; ! In C++03, the __TIME__ macro expands to some string literal and is concatenated with the other one. In C++11 __TIME__ isn't expanded, instead operator "" __TIME__ is being looked up, resulting in the following diagnostic: ! error: unable to find string literal operator âoperator"" __TIME__â --- 221,250 User-defined literals and whitespace ! The C++ compiler in ISO C11 mode std={c++11,c++0x,gnu++11,gnu++0x} supports user defined literals, which are incompatible with some valid ISO C++03 code. ! In particular, whitespace is now needed after a string literal and ! before something that could be a valid user defined literal. Take the ! valid ISO C++03 code ! const char *p = “foobar”__TIME__; ! In C++03, the __TIME__ macro expands to some string ! literal and is concatenated with the other one. In ! C++11 __TIME__ isn't expanded, instead operator ! "" __TIME__ is being looked up, resulting in the ! following diagnostic: ! error: unable to find string literal operator ‘operator“” __TIME__’
Re: [wwwdocs] gcc-4.7/porting_to.html
On 01/12/2012 01:11 AM, Benjamin Kosnik wrote: I thought it better to get this in, warts and all, and have it be corrected than to dally around again and have it not checked in. Is the file actually linked to? (Same question also applies to the 4.5 and 4.6 version.) The two most obvious places would be: gcc-4.{5,6,7}/changes.html and gcc-4.{5,6,7}/index.html - but I couldn't find the link in none of the files. For the 4.4 version there was - a rather hidden - link in http://gcc.gnu.org/gcc-4.4/changes.html (last item of the "Caveats" section). Tobias
Re: [wwwdocs] gcc-4.7/porting_to.html
On Wed, 11 Jan 2012, Benjamin Kosnik wrote: > + Boolean type promotion changes > + > + > + The C compiler no longer promotes boolean values in arithmetic > + statements to integer values. Configure-related code that checks for > + C99'smay be impacted. If the following line is > + newly present in configure logs, then support is > + incorrectly configured. > + This does not make sense to me as a description of any change in 4.7. > + > + checking for stdbool.h that conforms to C99... no > + That should have been fixed by: 2012-01-03 Richard Guenther PR middle-end/51730 * fold-const.c (fold_comparison): Properly canonicalize tree offset and HOST_WIDE_INT bit position. -- Joseph S. Myers jos...@codesourcery.com
Re: [wwwdocs] gcc-4.7/porting_to.html
> > + Boolean type promotion changes > > + > > + > > + The C compiler no longer promotes boolean values in arithmetic > > + statements to integer values. Configure-related code that checks > > for > > + C99'smay be impacted. If the following line is > > + newly present in configure logs, then support is > > + incorrectly configured. > > + > > This does not make sense to me as a description of any change in 4.7. > > > + > > + checking for stdbool.h that conforms to C99... no > > + > > That should have been fixed by: > > 2012-01-03 Richard Guenther > > PR middle-end/51730 > * fold-const.c (fold_comparison): Properly canonicalize > tree offset and HOST_WIDE_INT bit position. Ah. Yes, this would explain why I can no longer reproduce it. Sorry, this analysis was done before the third of January. Thanks. I was hoping to get a better explanation of this change/issue and you've provided it. best, Benjamin
Re: [wwwdocs] gcc-4.7/porting_to.html
Here's the page with links, more validation fixes, and removal of the C item. best, Benjamin2012-01-12 Benjamin Kosnik * htdocs/gcc-4.7/porting_to.html: Fixup for validation. * htdocs/gcc-4.7/changes.html: Add link to porting_to.html. * htdocs/gcc-4.6/changes.html: Add link to porting_to.html. Index: htdocs/gcc-4.6/changes.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.6/changes.html,v retrieving revision 1.136 diff -c -p -r1.136 changes.html *** htdocs/gcc-4.6/changes.html 30 Oct 2011 12:55:43 - 1.136 --- htdocs/gcc-4.6/changes.html 12 Jan 2012 19:33:38 - *** *** 125,130 --- 125,134 configurations obsoleted in GCC 4.5. + More information on porting to GCC 4.6 from previous versions + of GCC can be found in + the http://gcc.gnu.org/gcc-4.6/porting_to.html";>porting + guide for this release. General Optimizer Improvements Index: htdocs/gcc-4.7/changes.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/changes.html,v retrieving revision 1.72 diff -c -p -r1.72 changes.html *** htdocs/gcc-4.7/changes.html 30 Dec 2011 23:56:48 - 1.72 --- htdocs/gcc-4.7/changes.html 12 Jan 2012 19:33:38 - *** *** 50,55 --- 50,60 Support has been removed for the NetWare x86 configuration obsoleted in GCC 4.6. + + More information on porting to GCC 4.7 from previous versions + of GCC can be found in + the http://gcc.gnu.org/gcc-4.7/porting_to.html";>porting + guide for this release. Index: htdocs/gcc-4.7/porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/porting_to.html,v retrieving revision 1.4 diff -c -p -r1.4 porting_to.html *** htdocs/gcc-4.7/porting_to.html 12 Jan 2012 19:30:54 - 1.4 --- htdocs/gcc-4.7/porting_to.html 12 Jan 2012 19:33:38 - *** Invalid options need to be removed from *** 54,76 by something that is valid. - C language issues - - Boolean type promotion changes - - - The C compiler no longer promotes boolean values in arithmetic - statements to integer values. Configure-related code that checks for - C99'smay be impacted. If the following line is - newly present in configure logs, then support is - incorrectly configured. - - - - checking for stdbool.h that conforms to C99... no - - - C++ language issues Header dependency changes --- 54,59 *** const char *p = “foobar”__TI *** 237,248 In C++03, the __TIME__ macro expands to some string literal and is concatenated with the other one. In C++11 __TIME__ isn't expanded, instead operator ! "" __TIME__ is being looked up, resulting in the following diagnostic: ! error: unable to find string literal operator ‘operator“” __TIME__’ --- 220,232 In C++03, the __TIME__ macro expands to some string literal and is concatenated with the other one. In C++11 __TIME__ isn't expanded, instead operator ! “” __TIME__ is being looked up, resulting in the following diagnostic: ! error: unable to find string literal operator ! ‘operator“” __TIME__’
Re: [wwwdocs] gcc-4.7/porting_to.html
On Wed, 11 Jan 2012, Benjamin Kosnik wrote: > I thought it better to get this in, warts and all, and have it be > corrected than to dally around again and have it not checked in. Awesome. Seeing the validator errors, I figured I'll try and help, alas you only left a single one for me -- patch at the end. :-) + At no time, should user-level code use private Extra comma? + The C++ compiler no longer performs an extra unqualified lookups that + had performed in the past, namely http://gcc.gnu.org/PR24163";>dependant base class scope lookups and Grammaros? + C++ programs that depended on the compiler's previous behavior may + longer compile. For example, code such as "no" missing here. :) + + To fix this, rename the inner variable from i to a + distinct identifier. + "...rename one of the two variables..." I went ahead and created a small patch with the changes above which is the second patch below and committed it. If you'd like to see some changes, just let me know. Gerald Index: porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/porting_to.html,v retrieving revision 1.3 diff -u -3 -p -r1.3 porting_to.html --- porting_to.html 12 Jan 2012 02:52:22 - 1.3 +++ porting_to.html 12 Jan 2012 19:30:46 - @@ -204,9 +204,7 @@ int main() } - -Now results in the error: - +Now results in the error: error: redeclaration of ‘int i’ Index: porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/porting_to.html,v retrieving revision 1.5 diff -u -3 -p -r1.5 porting_to.html --- porting_to.html 12 Jan 2012 19:35:29 - 1.5 +++ porting_to.html 12 Jan 2012 21:14:06 - @@ -94,24 +94,25 @@ Fixing this issue is easy: just include Note on proper checking for thread support -At no time, should user-level code use private +At no time should user-level code use private GCC-implementation-space macros such as -_GLIBCXX_HAS_GTHREADS to determine at compile-time -concurrency support. Instead, use the POSIX -macro _REENTRANT. +_GLIBCXX_HAS_GTHREADS to determine concurrency support +at compile-time +Instead, use the POSIX macro _REENTRANT. Name lookup changes -The C++ compiler no longer performs an extra unqualified lookups that -had performed in the past, namely http://gcc.gnu.org/PR24163";>dependant base class scope lookups and -http://gcc.gnu.org/PR29131";>unqualified template function +The C++ compiler no longer performs some extra unqualified lookups it +had performed in the past, namely +http://gcc.gnu.org/PR24163";>dependant base class scope lookups +and http://gcc.gnu.org/PR29131";>unqualified template function lookups. -C++ programs that depended on the compiler's previous behavior may +C++ programs that depended on the compiler's previous behavior may no longer compile. For example, code such as @@ -195,7 +196,7 @@ error: ‘int i’ previously de -To fix this, rename the inner variable from i to a +To fix this, rename one of the two variables from i to a distinct identifier.
Re: [wwwdocs] gcc-4.7/porting_to.html
> I went ahead and created a small patch with the changes above which > is the second patch below and committed it. If you'd like to see > some changes, just let me know. Thanks Gerald! This looks good. For the links, I just tried to add them where they'd been added before. Seems reasonable -benjamin
[wwwdocs] gcc-4.7/porting_to.html says C11 not C++11
Committed as obvious.