[LLVMbugs] [Bug 23567] New: atomic_load() requiring a pointer to non-const is not helpful.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon May 18 15:47:21 PDT 2015
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: unassignedclangbugs at nondot.org
Reporter: toojays at toojays.net
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
jscott at 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 at 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 at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150518/bf0984c8/attachment.html>
More information about the llvm-bugs
mailing list