-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
| Bugzilla Link | 3912 |
| Resolution | FIXED |
| Resolved on | Feb 22, 2010 12:50 |
| Version | unspecified |
| OS | MacOS X |
| Reporter | LLVM Bugzilla Contributor |
Extended Description
version: checker-0.181
clang prints a warning message when a const qualified pointer is passed to __builtin_prefetch(). It would appear that clang thinks prefetch is defined along the lines of 'void __builtin_prefetch(void *)'.
expected behavior: clang shouldn't warn about this. Unless, of course, there's a compelling reason that clang doesn't want to treat the pointed to memory as const / read-only.
Small test demonstrating issue (distilled down from other sources):
#include <stdio.h>
#define PREFETCH_BUFFER(ptr, off) { const char *p = ((const char *)(ptr)) + ((off)) + 64U; __builtin_prefetch(p); }
int main(int argc, char *argv[]) {
char buffer[4096];
PREFETCH_BUFFER(&buffer[128], 32);
return(0);
}
output from clang:
clang_pf.c:8:3: warning: passing 'char const *' discards qualifiers, expected 'void *'
PREFETCH_BUFFER(&buffer[128], 32);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/johne/rkl/clang_pf.c:3:113: note: instantiated from:
#define PREFETCH_BUFFER(ptr, off) { const char *p = ((const char *)(ptr)) + ((off)) + 64U; __builtin_prefetch(p); }
From gcc-4.2/gcc/builtins.def, where GCC defines it as a const qualified pointer:
DEF_GCC_BUILTIN (BUILT_IN_PREFETCH, "prefetch", BT_FN_VOID_CONST_PTR_VAR, ATTR_NOVOPS_LIST)
Also: http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Other-Builtins.html#Other-Builtins =
Built-in Function: void __builtin_prefetch (const void *addr, ...)