[wwwdocs] gcc-4.6/porting_to.html
Needs some more work, here's a rough draft. -benjaminIndex: htdocs/gcc-4.6/porting_to.html === RCS file: htdocs/gcc-4.6/porting_to.html diff -N htdocs/gcc-4.6/porting_to.html *** /dev/null 1 Jan 1970 00:00:00 - --- htdocs/gcc-4.6/porting_to.html 17 Mar 2011 06:47:42 - *** *** 0 --- 1,167 + + + + GCC 4.6 Release Series — Porting to the New Tools + + + + GCC 4.6 Release SeriesPorting to the New Tools + + + The GCC 4.6 release series differs from previous GCC releases in more + than the usual list + of http://gcc.gnu.org/gcc-4.6/changes.html";>new + features. Some of these changes 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 GCC versions. + + + + However, some of these changes are visible, and can cause grief to + users porting to GCC 4.6. 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. + + + C language issues + + New warnings for unused variables and parameters + + + The behavior of -Wall has changed and now includes the + new warning flags -Wunused-but-set-variable and + (with -Wall + -Wextra) -Wunused-but-set-parameter. This may + result in new warnings in code that compiled cleanly with previous + versions of GCC. + + + + For example, + + + + void fn (void) + { + int foo; + foo = bar (); /* foo is never used. */ + } + + + + Gives the following diagnostic: + + + + warning: variable âfooâ set but not used [-Wunused-but-set-variable] + + + Although these warnings will + not result in compilation failure, often -Wall is used in + conjunction with -Werror and as a result, new warnings + are turned into new errors. + + + + To fix, first see if the unused variable or parameter can be removed + without changing the result or logic of the surrounding code. If not, + annoate it with __attribute__((__unused__)) + + + As a workaround, remove -Werror until the new warnings + are fixed, or for conversion warnings + add -Wno-unused-but-set-variable + or -Wno-unused-but-set-parameter. + + + Strict overflow warnings + + + Using the -Wstrict-overflow flag + with -Werror and optmization flags above -O2 + may result in compile errors when using glibc optimizations + for strcmp. + + + + For example, + + + + #include + void do_rm_rf (const char *p) { if (strcmp (p, "/") == 0) return; } + + + + Results in the following diagnostic: + + + + error: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow] + + + + To work around this, use -D__NO_STRING_INLINES. + + + C++ language issues + + Header dependency changes + + + Many of the standard C++ library include files have been edited to no + longer includeto get namespace std + -scoped versions of size_t and ptrdiff_t. + + + + As such, C++ programs that used the macros NULL + or offsetof without including will no + longer compile. The diagnostic produced is similar to: + + + + error: 'ptrdiff_t' does not name a type + + + + error: 'size_t' has not been declared + + + + error: 'NULL' 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 . + + + Java issues + + Links + + + Jakub Jelinek, http://lists.fedoraproject.org/pipermail/devel/2011-February/148523.html";>GCC 4.6 related common package rebuild failures (was Re: mass rebuild status) + + + + Matthias Klose, http://lists.debian.org/debian-devel-announce/2011/02/msg00012.html";>prepare to fix build failures with new GCC versions + + + + Jim Meyering, http://lists.fedoraproject.org/pipermail/devel/2011-March/149355.html";>gcc-4.6.0-0.12.fc15.x86_64 breaks strcmp? + + + + + + +
Re: [wwwdocs] gcc-4.6/porting_to.html
On Wed, 16 Mar 2011, Benjamin Kosnik wrote: > Needs some more work, here's a rough draft. s/Porting to the new tools/Porting to the new version/ ? brgds, H-P
Re: [wwwdocs] gcc-4.6/porting_to.html
On Wed, Mar 16, 2011 at 11:51:30PM -0700, Benjamin Kosnik wrote: > + > + To fix, first see if the unused variable or parameter can be removed > + without changing the result or logic of the surrounding code. If not, > + annoate it with __attribute__((__unused__)) annotate Also, I think we should mention that casting the var to void is another option. And I think it is worth mentioning that sometimes the RHS can have important side-effects, in which case it is desirable to just drop the LHS and =, while sometimes the RHS is just uselessly computed and can be dropped altogether with the assignment and unused variable. > + Strict overflow warnings > + > + > + Using the -Wstrict-overflow flag > + with -Werror and optmization flags above -O2 > + may result in compile errors when using glibc optimizations > + for strcmp. > + > + > + > + For example, > + > + > + > + #include > + void do_rm_rf (const char *p) { if (strcmp (p, "/") == 0) return; } > + This has been actually fixed, so we shouldn't mention this. > + > + Jim Meyering, href="http://lists.fedoraproject.org/pipermail/devel/2011-March/149355.html";>gcc-4.6.0-0.12.fc15.x86_64 > breaks strcmp? And this reference too. Thanks for writing this. Jakub
Re: [wwwdocs] gcc-4.6/porting_to.html
On Wed, 16 Mar 2011 23:51:30 -0700 Benjamin Kosnik wrote: > Needs some more work, here's a rough draft. The one I've seen most often other than including cstddef is due to linker options starting with -- (eg. --export-dynamic, --no-undefined) now being errors. Previously they were just silently ignored. The fix of course is to prepend "-Wl," to these flags. http://gcc.gnu.org/PR46410 -- fonts, gcc-porting, it makes no sense how it makes no sense toolchain, wxwidgets but i'll take it free anytime @ gentoo.orgEFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662 signature.asc Description: PGP signature
Re: [wwwdocs] gcc-4.6/porting_to.html
On 17.03.2011 07:51, Benjamin Kosnik wrote: > > Needs some more work, here's a rough draft. > > -benjamin + As a workaround, remove -Werror until the new warnings + are fixed, or for conversion warnings + add -Wno-unused-but-set-variable + or -Wno-unused-but-set-parameter. + what about recommending keeping -Werror and adding -Wno-error=unused-but-set-variable or -Wno-error=unused-but-set-parameter? Then the warnings remain, but don't cause an error. Matthias
Re: [wwwdocs] gcc-4.6/porting_to.html
Hi Benjamin, On Wed, 16 Mar 2011, Benjamin Kosnik wrote: > Needs some more work, here's a rough draft. I realized this one hasn't made it in, but is really nice. I made a number of minor edits (typos, markup, simplifying headings,... among others). What do you think -- should we include this? Many users still won't have GCC 4.6 deployed yet, so I think it's still worth it. What do you think? Gerald Index: porting_to.html === RCS file: porting_to.html diff -N porting_to.html --- /dev/null 1 Jan 1970 00:00:00 - +++ porting_to.html 11 Oct 2011 04:47:14 - @@ -0,0 +1,142 @@ + + + +Porting to GCC 4.6 + + + +Porting to GCC 4.6 + + +The GCC 4.6 release series differs from previous GCC releases in more +than the usual list of +http://gcc.gnu.org/gcc-4.6/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 +instandards-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.6. 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. + + +C language issues + +New warnings for unused variables and parameters + + +The behavior of -Wall has changed and now includes the +new warning flags -Wunused-but-set-variable and +(with -Wall +-Wextra) -Wunused-but-set-parameter. This may +result in new warnings in code that compiled cleanly with previous +versions of GCC. + + + +For example, + + void fn (void) + { +int foo; +foo = bar (); /* foo is never used. */ + } + +Gives the following diagnostic: + +warning: variable "foo" set but not used [-Wunused-but-set-variable] + + +low flag +with -Werror and optimization flags above -O2 +may result in compile errors when using glibc optimizations +for strcmp. + + + +For example, + +#include +void do_rm_rf (const char *p) { if (strcmp (p, "/") == 0) return; } + +Results in the following diagnostic: + +error: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow] + + + + +To work around this, use -D__NO_STRING_INLINES. + + +C++ language issues + +Header dependency changes + + +Many of the standard C++ library include files have been edited to no +longer includeto get namespace std +-scoped versions of size_t and ptrdiff_t. + + + +As such, C++ programs that used the macros NULL +or offsetof without including will no +longer compile. The diagnostic produced is similar to: + + + +error: 'ptrdiff_t' does not name a type + + + +error: 'size_t' has not been declared + + + +error: 'NULL' 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 . + + + + +Links + + +Jakub Jelinek, + http://lists.fedoraproject.org/pipermail/devel/2011-February/148523.html";>GCC +4.6 related common package rebuild failures (was Re: mass rebuild status) + + + +Matthias Klose, +http://lists.debian.org/debian-devel-announce/2011/02/msg00012.html";>prepare +to fix build failures with new GCC versions + + + +Jim Meyering, + http://lists.fedoraproject.org/pipermail/devel/2011-March/149355.html";>gcc-4.6.0-0.12.fc15.x86_64 breaks strcmp? + + + + + + + +
Re: [wwwdocs] gcc-4.6/porting_to.html
> I realized this one hasn't made it in, but is really nice. I made a > number of minor edits (typos, markup, simplifying headings,... among > others). What do you think -- should we include this? > > Many users still won't have GCC 4.6 deployed yet, so I think it's > still worth it. > > What do you think? Ouch. I see this is not in, and I though I checked in the draft months ago. Please check this in immediately!!! -benjamin
Re: [wwwdocs] gcc-4.6/porting_to.html
On Tue, 11 Oct 2011, Benjamin Kosnik wrote: >> Many users still won't have GCC 4.6 deployed yet, so I think it's >> still worth it. > Ouch. I see this is not in, and I though I checked in the draft months > ago. > > Please check this in immediately!!! Done last evening, and made some further tweaks. For reference hre is the full patch that's now live on the system. Gerald Index: porting_to.html === RCS file: porting_to.html diff -N porting_to.html --- /dev/null 1 Jan 1970 00:00:00 - +++ porting_to.html 12 Oct 2011 16:16:54 - 1.3 @@ -0,0 +1,150 @@ + + + +Porting to GCC 4.6 + + + +Porting to GCC 4.6 + + +The GCC 4.6 release series differs from previous GCC releases in more +than the usual list of +http://gcc.gnu.org/gcc-4.6/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 +instandards-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.6. 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. + + +C language issues + +New warnings for unused variables and parameters + + +The behavior of -Wall has changed and now includes the +new warning flags -Wunused-but-set-variable and +(with -Wall +-Wextra) -Wunused-but-set-parameter. This may +result in new warnings in code that compiled cleanly with previous +versions of GCC. + + +For example, + + void fn (void) + { +int foo; +foo = bar (); /* foo is never used. */ + } + +Gives the following diagnostic: + +warning: variable "foo" set but not used [-Wunused-but-set-variable] + + +Although these warnings will not result in compilation failure, +often -Wall is used in conjunction with +-Werror and as a result, new warnings are turned into +new errors. + +To fix, first see if the unused variable or parameter can be removed +without changing the result or logic of the surrounding code. If not, +annotate it with __attribute__((__unused__)). + +As a workaround, remove -Werror until the new warnings +are fixed. For conversion warnings add +-Wno-unused-but-set-variable or +-Wno-unused-but-set-parameter. + +Strict overflow warnings + +Using the -Wstrict-overflow flag with +-Werror and optmization flags above -O2 +may result in compile errors when using glibc optimizations +for strcmp. + +For example, + +#include+void do_rm_rf (const char *p) { if (strcmp (p, "/") == 0) return; } + +Results in the following diagnostic: + +error: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow] + + +To work around this, use -D__NO_STRING_INLINES. + +C++ language issues + +Header dependency changes + + +Many of the standard C++ library include files have been edited to no +longer include to get namespace std +-scoped versions of size_t and ptrdiff_t. + + + +As such, C++ programs that used the macros NULL +or offsetof without including will no +longer compile. The diagnostic produced is similar to: + + + +error: 'ptrdiff_t' does not name a type + + + +error: 'size_t' has not been declared + + + +error: 'NULL' 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 . + + + + +Links + + +Jakub Jelinek, + http://lists.fedoraproject.org/pipermail/devel/2011-February/148523.html";>GCC +4.6 related common package rebuild failures (was Re: mass rebuild status) + + + +Matthias Klose, +http://lists.debian.org/debian-devel-announce/2011/02/msg00012.html";>prepare +to fix build failures with new GCC versions + + + +Jim Meyering, + http://lists.fedoraproject.org/pipermail/devel/2011-March/149355.html";>gcc-4.6.0-0.12.fc15.x86_64 breaks strcmp? + + + + + +
Re: [wwwdocs] gcc-4.6/porting_to.html
On Mon, 10 Oct 2011, Gerald Pfeifer wrote: > I realized this one hasn't made it in, but is really nice. I made a > number of minor edits (typos, markup, simplifying headings,... among > others). What do you think -- should we include this? Checking mailing list archives I realized that Jakub had provided feedback ( http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00987.html ) that the strict overflow warnings had been fixed. Hence I went ahead and committed the removal below. Gerald Index: porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.6/porting_to.html,v retrieving revision 1.3 diff -u -r1.3 porting_to.html --- porting_to.html 12 Oct 2011 16:16:54 - 1.3 +++ porting_to.html 24 Oct 2011 00:52:53 - @@ -65,24 +65,6 @@ -Wno-unused-but-set-variable or -Wno-unused-but-set-parameter. -Strict overflow warnings - -Using the -Wstrict-overflow flag with --Werror and optmization flags above -O2 -may result in compile errors when using glibc optimizations -for strcmp. - -For example, - -#include-void do_rm_rf (const char *p) { if (strcmp (p, "/") == 0) return; } - -Results in the following diagnostic: - -error: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow] - - -To work around this, use -D__NO_STRING_INLINES. C++ language issues @@ -139,11 +121,6 @@ to fix build failures with new GCC versions - -Jim Meyering, - http://lists.fedoraproject.org/pipermail/devel/2011-March/149355.html";>gcc-4.6.0-0.12.fc15.x86_64 breaks strcmp? - -
Re: [wwwdocs] gcc-4.6/porting_to.html
[Sorry for the delay, catching up after being away] Gerald Pfeifer writes: > On Mon, 10 Oct 2011, Gerald Pfeifer wrote: >> I realized this one hasn't made it in, but is really nice. I made a >> number of minor edits (typos, markup, simplifying headings,... among >> others). What do you think -- should we include this? > > Checking mailing list archives I realized that Jakub had provided > feedback ( http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00987.html ) > that the strict overflow warnings had been fixed. > > Hence I went ahead and committed the removal below. Thanks for doing this. I noticed a typo while reading it, so I committed the patch below as obvious. Richard Index: porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.6/porting_to.html,v retrieving revision 1.4 diff -u -r1.4 porting_to.html --- porting_to.html 24 Oct 2011 00:57:54 - 1.4 +++ porting_to.html 15 Nov 2011 13:38:10 - @@ -13,7 +13,7 @@ http://gcc.gnu.org/gcc-4.6/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 -instandards-conforming ways to facilitate compilation or runtime +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.
Re: [wwwdocs] gcc-4.6/porting_to.html
On Wed, 12 Oct 2011, Gerald Pfeifer wrote: > For reference hre is the full patch that's now live on the system. And this take into account a suggestion by Matthias Klose (cf. http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01014.html ). Applied. Gerald Index: porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.6/porting_to.html,v retrieving revision 1.5 diff -u -r1.5 porting_to.html --- porting_to.html 15 Nov 2011 13:38:24 - 1.5 +++ porting_to.html 19 Nov 2011 16:56:39 - @@ -60,10 +60,9 @@ without changing the result or logic of the surrounding code. If not, annotate it with __attribute__((__unused__)). -As a workaround, remove -Werror until the new warnings -are fixed. For conversion warnings add --Wno-unused-but-set-variable or --Wno-unused-but-set-parameter. +As a workaround, add +-Wno-error=unused-but-set-variable or +-Wno-error=unused-but-set-parameter. C++ language issues
[wwwdocs] gcc-4.6/porting_to.html -- lists.fedoraproject.org is on https now
This is the only reference to lists.fedoraproject.org that I found via http; all others already are https. Committed. Index: gcc-4.6/porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.6/porting_to.html,v retrieving revision 1.8 diff -u -r1.8 porting_to.html --- gcc-4.6/porting_to.html 28 Jun 2015 14:54:03 - 1.8 +++ gcc-4.6/porting_to.html 28 Feb 2016 19:42:35 - @@ -109,7 +109,7 @@ Jakub Jelinek, - http://lists.fedoraproject.org/pipermail/devel/2011-February/148523.html";>GCC + https://lists.fedoraproject.org/pipermail/devel/2011-February/148523.html";>GCC 4.6 related common package rebuild failures (was Re: mass rebuild status)