From patchwork Tue Oct 11 04:49:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Pfeifer X-Patchwork-Id: 118861 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 799F8B6F6B for ; Tue, 11 Oct 2011 15:50:18 +1100 (EST) Received: (qmail 6302 invoked by alias); 11 Oct 2011 04:50:10 -0000 Received: (qmail 6284 invoked by uid 22791); 11 Oct 2011 04:50:04 -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; Tue, 11 Oct 2011 04:49:49 +0000 Received: from [107.17.43.42] (unknown [107.17.43.42]) by ainaz.pair.com (Postfix) with ESMTPSA id BFD273F40F; Tue, 11 Oct 2011 00:49:47 -0400 (EDT) Date: Mon, 10 Oct 2011 22:49:48 -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: <20110316235130.1f44d808@shotwell> Message-ID: References: <20110316235130.1f44d808@shotwell> MIME-Version: 1.0 Content-Disposition: INLINE 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 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 -0000 +++ porting_to.html 11 Oct 2011 04:47:14 -0000 @@ -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 +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 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? +

+ + + + + + +