From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18586 invoked by alias); 5 Mar 2013 19:00:45 -0000 Received: (qmail 18568 invoked by uid 22791); 5 Mar 2013 19:00:43 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-vb0-f49.google.com (HELO mail-vb0-f49.google.com) (209.85.212.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Mar 2013 19:00:38 +0000 Received: by mail-vb0-f49.google.com with SMTP id s24so1376835vbi.8 for ; Tue, 05 Mar 2013 11:00:37 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.52.175.66 with SMTP id by2mr9086129vdc.53.1362510037395; Tue, 05 Mar 2013 11:00:37 -0800 (PST) Received: by 10.220.205.90 with HTTP; Tue, 5 Mar 2013 11:00:37 -0800 (PST) Reply-To: noloader@gmail.com In-Reply-To: References: Date: Tue, 05 Mar 2013 19:00:00 -0000 Message-ID: Subject: Re: Question on volatile functions and GCC From: Jeffrey Walton To: Jonathan Wakely Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 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/msg00045.txt.bz2 On Mon, Mar 4, 2013 at 6:46 PM, Jonathan Wakely wrote: > On 4 March 2013 23:40, Jeffrey Walton wrote: >> 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) >> ;; >> } > > This doesn't compile, it dereferences void. Did you mean p[--len] ? Yes, my bad. Sorry - copy[paste was not available because the slide was an umage. >> How does a function become a 'volatile' memory mapped object related >> to hardware? > > The function isn't volatile, the return type is. Qualifying void as > volatile is meaningless, but allowed by the C grammar. :) Jeff