https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69407
Bug ID: 69407 Summary: -Wunused-value on __atomic_fetch_OP and __atomic_OP_fetch Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Invoking the __atomic_fetch_OP and __atomic_OP_fetch intrinsics without using their return value elicits a -Wunused-value warning. The warning doesn't seem useful, especially in the __atomic_OP_fetch(ptr, val) case, since a) whether the computed value is used impossible to determine at the call site, and b) the corresponding (*ptr OP= val) expressions don't cause any warnings. (As expected, the warnings can be suppressed by casting the result ti void). No other CCC-compatible compiler emits warnings for these intrinsics. $ cat z.c && /home/msebor/build/gcc-trunk-git/gcc/xgcc -B/home/msebor/build/gcc-trunk-git/gcc -S -Wall -Wextra -Wpedantic -o/dev/null z.c void foo (int*i, int); void foo (int *p, int a) { __atomic_fetch_add (&p, a, 0); __atomic_add_fetch (&p, a, 0); } z.c: In function ‘foo’: z.c:5:5: warning: value computed is not used [-Wunused-value] __atomic_fetch_add (&p, a, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ z.c:6:5: warning: value computed is not used [-Wunused-value] __atomic_add_fetch (&p, a, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~