Page MenuHome GnuPG

Disable optimizations on one function (was: 'pragma optimize' ...)
Closed, ResolvedPublic


Hi Gentleman,

Re: Issue 1878.

Below is a new definition of volatile. Andrew also provides advice,
and it might help GnuPG put the issue to bed once and for all.
Personally, I like asm volatile("": : : "memory");.

(I'm not sure what to do when Ian and Andrew don't exactly sync, though).


  • Forwarded message ----------

From: Jeffrey Walton <>
Date: Thu, Jul 16, 2015 at 5:40 AM
Subject: Re: Disable optimizations on one function (was: 'pragma optimize' ...)
To: Andrew Haley <>
Cc: "" <>

Many folks try and cast ptr to volatile, but that's an abuse because
GCC considers volatile something for memory mapped hardware. Volatile
should not be used in an attempt to tame the optimizer.

GCC does not consider volatile to be something for memory mapped

OK, this appears to be creating a moving definition (or the definition
has changed since I took note of it). I took the last definition from
Ian Lance Taylor. See and, for

If you don't mind being nonportable, a memoryclobber should do it:

memset(ptr, 0x00, n);
asm volatile("": : : "memory");

or even:

memset(ptr, 0x00, n);

Perfect, thanks.


Event Timeline

neal triaged this task as Normal priority.Jul 16 2015, 12:08 PM
neal added a project: Bug Report.

Thanks for researching this. We'll take a look at this soon. I'm confused
about whey you didn't just add this to T1878. Is this a separate issue?

werner claimed this task.

See T1878.