This is the mail archive of the
mailing list for the GCC project.
Re: linux says it is a bug
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: lin zuojian <manjian2006 at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Tue, 4 Mar 2014 10:10:21 +0100
- Subject: Re: linux says it is a bug
- Authentication-results: sourceware.org; auth=none
- References: <20140304064026 dot GE8019 at ubuntu>
On Tue, Mar 4, 2014 at 7:40 AM, lin zuojian <firstname.lastname@example.org> wrote:
> 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,
The term "optimization barrier" isn't well-defined.