yskzalloc wrote:

Hi, Have you tested this case for this flag?
```c
// $ clang -std=gnu11 -Werror=unsequenced-volatile -fsyntax-only jiffies.c
extern volatile unsigned long jiffies;

struct sample {
    unsigned long a;
    unsigned long b;
};

void init(struct sample *p)
{
    *p = (struct sample) {
        .a = jiffies,
        .b = jiffies,
    };
}
```

```sh
$ clang --version --verbose
clang version 24.0.0git (https://github.com/yskzalloc/llvm-project.git 
5d20c85f4e1b8755b655bf1782b094fb35ec48d1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: 
/home/debian-sid/kcov-dataflow/llvm-project/build-upstream-check/bin

$ clang -std=gnu11 -Werror=unsequenced-volatile -fsyntax-only jiffies.c
jiffies.c:12:14: error: unsequenced accesses to volatile qualified 'jiffies' 
[-Werror,-Wunsequenced-volatile]
   11 |         .a = jiffies,
      |              ~~~~~~~
   12 |         .b = jiffies,
      |              ^
1 error generated.
```

@nickdesaulniers  It causes the Linux kernel build with LLVM to fail.
```
kernel/sched/build_utility.c:86:
kernel/sched/topology.c:2008:29: error: unsequenced accesses to volatile 
qualified 'jiffies' [-Werror,-Wunsequenced-volatile]
 1998 |                 .last_balance           = jiffies,
      |                                           ~~~~~~~
 1999 |                 .balance_interval       = sd_weight,
 2000 | 
 2001 |                 /* 50% success rate */
 2002 |                 .newidle_call           = 512,
 2003 |                 .newidle_success        = 256,
 2004 |                 .newidle_ratio          = 512,
 2005 |                 .newidle_stamp          = now,
 2006 | 
 2007 |                 .max_newidle_lb_cost    = 0,
 2008 |                 .last_decay_max_lb_cost = jiffies,
      |                                           ^
1 error generated.
```
@aeubanks Is there something wrong in the linux kernel code, or is this a false 
positive?


https://github.com/llvm/llvm-project/pull/244073
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to