https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69404
Bug ID: 69404
Summary: atomic builtins silently discard cv-qualifiers
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The atomic builtins such as __atomic_load and __atomic_exchange silently
discard qualifiers from the types of their operands. The following test case
compiles without a warning with 6.0:
$ 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
int* foo (const int *p)
{
int *q;
__atomic_load (&p, &q, 0);
return q;
}
int* bar (const volatile int *p)
{
int *q;
__atomic_exchange (&p, &p, &q, 0);
return q;
}
The same test case produces the warnings below with Clang:
$ /build/llvm-trunk/bin/clang -S z.c
z.c:4:24: warning: passing 'int **' to parameter of type 'const int **'
discards
qualifiers in nested pointer types
[-Wincompatible-pointer-types-discards-qualifiers]
__atomic_load (&p, &q, 0);
^~
z.c:11:32: warning: passing 'int **' to parameter of type
'const volatile int **' discards qualifiers in nested pointer types
[-Wincompatible-pointer-types-discards-qualifiers]
__atomic_exchange (&p, &p, &q, 0);
^~
2 warnings generated.