[cfe-dev] [RFC] add Function Attribute to disable optimization

Jeffrey Walton noloader at gmail.com
Mon Jun 17 23:03:45 PDT 2013


On Tue, Jun 18, 2013 at 1:16 AM, Joshua Cranmer <pidgeot18 at gmail.com> wrote:
> On 6/17/2013 7:23 PM, Jeffrey Walton wrote:
>>
>> Microsoft was not the problem - it was GCC since the only use of volatile
>> is memory mapped hardware.
>
> That is a gross misrepresentation of volatile, I think.
Well... "The volatile qualifier is designed for working with memory
mapped hardware,"
http://gcc.gnu.org/ml/gcc-help/2012-03/msg00242.html.

(For what its worth, I don't disagree with you. Its a PITA to work
around GCC at times when the code is otherwise portable).

> ...
>> volatile void clean_memory(volatile void* dest, size_t len)
>> {
>>      volatile unsigned char* p;
>>      for(p = (volatile unsigned char*)dest; len; dest[--len] = 0)
>>        ;;
>> }
>>
>> Because the pointers above ('dest' and `p`) were not memory mapped
>> addresses, the GCC folks consider it an abuse.
>
> Did you actively ask them this question, or are you surmising from what
> you've read on lists?
Yes, it was actively asked. I lifted it a bit because I knew that
volatile was reserved for memory mapped addresses in GCC (from
previous discussions). This question asked how a function could be
volatile if the qualifier was reserved for memory mapped addresses.
http://gcc.gnu.org/ml/gcc-help/2013-03/msg00024.html.

> For your use case--zeroing out memory so people can't
> sneak read your memory map [1]--I would consider it a valid use myself; I
> would be surprised if a compiler developer disagreed with this solely on the
> basis that it's not clearing out a memory mapped address space.
Yes, its crypto. You should see they way OpenSSL handles it (see
OpenSSL_cleanse).

Jeff



More information about the cfe-dev mailing list