From owner-svn-src-all@FreeBSD.ORG Mon Mar 26 07:31:49 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B4511065672; Mon, 26 Mar 2012 07:31:49 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id A7FD78FC0A; Mon, 26 Mar 2012 07:31:48 +0000 (UTC) Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q2Q7VjpQ000605 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 26 Mar 2012 18:31:46 +1100 Date: Mon, 26 Mar 2012 18:31:45 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Alexander Kabaev In-Reply-To: <20120325162528.7f73300c@kan.dyndns.org> Message-ID: <20120326173737.U827@besplex.bde.org> References: <201203212055.q2LKtMYR093218@svn.freebsd.org> <20120325162528.7f73300c@kan.dyndns.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, Marius Strobl , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org Subject: Re: svn commit: r233288 - in head/sys: boot/common libkern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2012 07:31:49 -0000 On Sun, 25 Mar 2012, Alexander Kabaev wrote: > On Wed, 21 Mar 2012 20:55:22 +0000 (UTC) > Marius Strobl wrote: > > >> Modified: head/sys/sys/libkern.h >> ============================================================================== >> --- head/sys/sys/libkern.h Wed Mar 21 20:53:47 2012 >> (r233287) +++ head/sys/sys/libkern.h Wed Mar 21 20:55:21 >> 2012 (r233288) @@ -121,7 +121,7 @@ size_t strspn(const >> char *, const char char *strstr(const char *, const char *); >> int strvalid(const char *, size_t); >> >> -extern uint32_t crc32_tab[]; >> +extern const uint32_t const crc32_tab[]; >> >> static __inline uint32_t >> crc32_raw(const void *buf, size_t size, uint32_t crc) > > g++ produces "error: duplicate 'const'" on this changed line. Leaving > the question as to why this file is ever being compiled by C++ on the > conscience of of VirtualBox authors, I would suggest partially backing > out this commit and getting easier on 'const' for C++'s sake. It does have a duplicate `const'. This is not just a style bug, since duplicate type qualifiers are a constraint error in C90, and apparently in C++. TenDRA says that it violates [ISO C90 6.5.3], and indeed 6.5.3 says: Constraints The same type qualifier shall not appear more than once... either directly [as here] or via one or more typedefs. 6.5.3 in C90 corresponds to 6.7.3 in C99, and C99 no longer says this. This change causes many confusing variations in behaviour: For CC=gcc-3.3.3: - ${CC} without -pedantic warns about this - ${CC} -std=c89 without -pedantic warns about this - ${CC} -std=c99 with -pedantic doesn't warn about this (correct) For CC=gcc-3.4.6 and gcc-4.2.1: - ${CC} without -pedantic doesn't warn about this (broken) - ${CC} with -pedantic warns about this - ${CC} -std=c89 without -pedantic doesn't warn about this (broken) - ${CC} -std=c99 with -pedantic doesn't warn about this (correct) For CC=clang: - ${CC} without -pedantic doesn't warn about this (broken) - ${CC} with -pedantic doesn't warn about this (broken) (maybe it defaults to c99, but that is an even larger incompatibility) - ${CC} -std=c89 without -pedantic doesn't warn about this (broken) - ${CC} -std=c99 with -pedantic doesn't warn about this (correct) For C++: apparently, closest to gcc-3.3.3 and C90. There are also complications with warnings being broken by default in "system" headers: - if libkern.h is a "system" header, then to detect this bug in it, -Wsystem-headers must be added to CFLAGS for one the non-broken cases non-c99 cases above. Bruce