On Tue, Mar 4, 2014 at 7:40 AM, lin zuojian <manjian2...@gmail.com> wrote:
> Hi,
>     in include/linux/compiler-gcc.h :
>
> /* Optimization barrier */
> /* The "volatile" is due to gcc bugs */
> #define barrier() __asm__ __volatile__("": : :"memory")
>
> The comment of Linux says this is a gcc bug.But will any sane compiler
> disable optimization without "volatile" key word?

Depends what they call an "optimization barrier".  A plain
__asm__ ("" : : : "memory") is a memory barrier.  Adding volatile
to the asm makes it a barrier for every other volatile instruction,
nothing more.

The term "optimization barrier" isn't well-defined.

Richard.

Reply via email to