https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96327

--- Comment #1 from Paul McKenney <paulmckrcu at gmail dot com> ---
This manifests on GCC trunk (see the godbolt.org URL), but was first noted in
gcc version 7.5.0.  This is specific to x86, but might apply to any other
architecture that provides increment-memory instructions.  This behavior does
not seem to be affected by GCC options.

This can be reproduced by placing the sample code in a file "rrl.c" and
running:

cc -o rrl rrl.c

This completes successfully with no error or warnings.

Running "cc -o rrl rrl.c --save-temps" generates the following file:

# 1 "rrl.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "rrl.c"
struct task {
    int other;
    int rcu_count;
};

struct task *current;

void rcu_read_lock()
{
    (*(volatile int*)&current->rcu_count)++;
}

Reply via email to