From patchwork Wed Oct 12 23:38:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Pfeifer X-Patchwork-Id: 119329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D7ACDB6F18 for ; Thu, 13 Oct 2011 10:39:20 +1100 (EST) Received: (qmail 26159 invoked by alias); 12 Oct 2011 23:39:16 -0000 Received: (qmail 26148 invoked by uid 22791); 12 Oct 2011 23:39:14 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from ainaz.pair.com (HELO ainaz.pair.com) (209.68.2.66) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 12 Oct 2011 23:38:58 +0000 Received: from [10.32.80.122] (unknown [70.102.180.10]) by ainaz.pair.com (Postfix) with ESMTPSA id 291D23F40F; Wed, 12 Oct 2011 19:38:56 -0400 (EDT) Date: Wed, 12 Oct 2011 17:38:55 -0600 (MDT) From: Gerald Pfeifer To: Benjamin Kosnik cc: gcc-patches@gcc.gnu.org Subject: Re: [wwwdocs] gcc-4.6/porting_to.html In-Reply-To: <20111011151208.3ee01394@shotwell> Message-ID: References: <20110316235130.1f44d808@shotwell> <20111011151208.3ee01394@shotwell> MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 -0000 +++ porting_to.html 12 Oct 2011 16:16:54 -0000 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 +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 <string.h>
+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 <cstddef> 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 <cstddef> 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 <cstddef>. +

+ + + +

Links

+ +

+Jakub Jelinek, + GCC +4.6 related common package rebuild failures (was Re: mass rebuild status) +

+ +

+Matthias Klose, +prepare +to fix build failures with new GCC versions +

+ +

+Jim Meyering, + gcc-4.6.0-0.12.fc15.x86_64 breaks strcmp? +

+ + + + +