From owner-freebsd-ports@FreeBSD.ORG Mon Sep 5 16:43:59 2011 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38998106566C for ; Mon, 5 Sep 2011 16:43:59 +0000 (UTC) (envelope-from matthias.andree@gmx.de) Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mx1.freebsd.org (Postfix) with SMTP id 98F028FC0A for ; Mon, 5 Sep 2011 16:43:58 +0000 (UTC) Received: (qmail invoked by alias); 05 Sep 2011 16:43:56 -0000 Received: from g225212086.adsl.alicedsl.de (EHLO apollo.emma.line.org) [92.225.212.86] by mail.gmx.net (mp046) with SMTP; 05 Sep 2011 18:43:56 +0200 X-Authenticated: #428038 X-Provags-ID: V01U2FsdGVkX1/OlmxKm1nObnJqqoAsX6zaEuJed6IHmz9wCJFfuT ac8Vdxs1Woyp49 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by apollo.emma.line.org (Postfix) with ESMTP id D1F2523D35A for ; Mon, 5 Sep 2011 18:43:45 +0200 (CEST) Message-ID: <4E64FC41.2080702@gmx.de> Date: Mon, 05 Sep 2011 18:43:45 +0200 From: Matthias Andree User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Mnenhy/0.8.3 Thunderbird/3.1.13 MIME-Version: 1.0 To: freebsd-ports@freebsd.org References: <20110725155920.GA83490@freebsd.org> <4E631DBF.9000106@yandex.ru> <20110904101252.526de5ef@nonamehost.> <4E632A09.8060904@FreeBSD.org> <20110904114550.71c63078@nonamehost.> <4E63516B.7000805@FreeBSD.org> <20110904130659.7a94cce8@raksha.tavi.co.uk> <4E637DD8.50700@gmx.de> <4e6491d0.MNLKNzL63JK0kXDG%perryh@pluto.rain.com> In-Reply-To: <4e6491d0.MNLKNzL63JK0kXDG%perryh@pluto.rain.com> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Subject: Re: reasons for rewriting regular memory X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Sep 2011 16:43:59 -0000 Am 05.09.2011 11:09, schrieb perryh@pluto.rain.com: > Matthias Andree wrote: >>> I agree, but I can think of another valid exception. System with >>> Hamming correction on the memory, gets a single bit (correctable) >>> error. Need to rewrite the memory contents to reset all the parity >>> bits! >> That's a matter of the EDAC stuff, not the business of applications. > > True, but it may explain why clang does not flag "*x = *x;" when it > does flag "x = x;". A compiler cannot know the context in which the > compiled code will be used. And a compiler is free to optimize either away unless the storage class is "volatile", so the original point stands: > BTW I agree that an understanding is needed of _why_ the code in > question was included. Which waits on the original author. On the other issue: > I have seen "x = x;" -- x being a formal > parameter -- used to prevent an "unused argument" warning in a > function which did not in fact need the argument in question, but > had to declare it for uniformity with other functions pointed to > by the same function pointer type. The portable and concise solution is to cast unused arguments to void, as in this example: int f(int used, int unused) { (void)unused; // avoids warnings // ... // now do something with used // ... return 42; }