This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: linux says it is a bug


On Tue, Mar 4, 2014 at 7:40 AM, lin zuojian <manjian2006@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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]