From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 363 invoked by alias); 5 Mar 2013 09:46:25 -0000 Received: (qmail 354 invoked by uid 22791); 5 Mar 2013 09:46:24 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Mar 2013 09:46:00 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGOZE+TiTS5oCO9h49K+m0= X-RZG-CLASS-ID: mo00 Received: from [192.168.2.100] (dslb-084-058-200-159.pools.arcor-ip.net [84.58.200.159]) by smtp.strato.de (joses mo23) (RZmta 31.19 DYNA|AUTH) with ESMTPA id I026acp258xwFn ; Tue, 5 Mar 2013 10:45:57 +0100 (CET) Message-ID: <5135BE7F.8030008@gjlay.de> Date: Tue, 05 Mar 2013 09:46:00 -0000 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: noloader@gmail.com CC: gcc-help@gcc.gnu.org Subject: Re: Question on volatile functions and GCC References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00031.txt.bz2 Jeffrey Walton schrieb: > Hi All, > > I was looking at some slides on OpenSSL and secure memory wiping using > volatile (Slide 36 at > http://www.slideshare.net/guanzhi/crypto-with-openssl). > > I believe GCC's interpretation of the use for 'volatile' is memory > mapped hardware. I think Ian stated it for me some time ago when I was > trying to understand different interpretations among compilers. If > volatile is for memory mapped hardware, why does GCC compile the > following: > > volatile void clean_memory(volatile void* dest, size_t len) > { > volatile unsigned char* p; > for(p = (volatile unsigned char*)dest; len; dest[--len] = 0) > ;; > } > > How does a function become a 'volatile' memory mapped object related > to hardware? volatile can be used to express that a function is noreturn like in the following example where only one call of f() is issued: typedef void ft (void); volatile ft f; void foo (void) { f(); f(); } or this example that throws : In function 'f': :4:1: warning: 'noreturn' function does return [enabled by default] typedef void ft (void); volatile ft f; void f (void) {} In your example, the volatile looks meaningless and like a typo. Johann