https://llvm.org/bugs/show_bug.cgi?id=23567
Bug ID: 23567
Summary: atomic_load() requiring a pointer to non-const is not
helpful.
Product: clang
Version: 3.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
jscott@citra:/tmp$ cat atomic.c
/* The following lines work around Clang bug 22740, where Clang tries to use
* GCC's stdatomic.h, and fails.
*/
#include <stddef.h>
#include <stdint.h>
#undef __STDC_HOSTED__
#define __STDC_HOSTED__ 0
#define __CLANG_STDINT_H
#include <stdatomic.h>
#undef __CLANG_STDINT_H
#undef __STDC_HOSTED__
#define __STDC_HOSTED__ 1
struct s
{
atomic_int i;
};
int f (const struct s *p_s)
{
return atomic_load(&p_s->i);
}
jscott@citra:/tmp$ clang -std=c11 -c atomic.c
atomic.c:21:10: error: address argument to atomic operation must be a pointer
to non-const _Atomic type ('const atomic_int *' (aka 'const _Atomic(int) *')
invalid)
return atomic_load(&p_s->i);
^ ~~~~~~~
/usr/lib/llvm-3.6/bin/../lib/clang/3.6.1/include/stdatomic.h:134:29: note:
expanded from macro 'atomic_load'
#define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
^
1 error generated.
My reading suggests that although this is a strictly correct interpretation of
the C11 standard, it isn't useful. There's no practical reason why
atomic_load() shouldn't accept a pointer to non-const.
Martin Sebor has submitted C defect report 459 about this.
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_459.htm>
jscott@citra:/tmp$ clang --version
Ubuntu clang version 3.6.1-svn236856-1~exp1 (branches/release_36) (based on
LLVM 3.6.1)
Target: x86_64-pc-linux-gnu
Thread model: posix
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs