issue about overloading functions with size_t and ulong arguments

Hi,

I got an issue when overloading functions with size_t and ulong arguments:

$ cat overload.cl

#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable

#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable

__attribute__((overloadable)) void foo(ulong a){}
__attribute__((overloadable)) void foo(size_t a){}
__attribute__((overloadable)) void foo(long a){}
__attribute__((overloadable)) void foo(intptr_t a){}
__attribute__((overloadable)) void foo(atomic_ulong a){}
__attribute__((overloadable)) void foo(atomic_size_t a){}
__attribute__((overloadable)) void foo(atomic_long a){}
__attribute__((overloadable)) void foo(atomic_intptr_t a){}

$ clang -cc1 -cl-std=CL2.0 -triple amdgcn -finclude-default-header overload.cl

overload.cl:4:36: error: redefinition of 'foo'
__attribute__((overloadable)) void foo(size_t a){}
                                   ^
overload.cl:3:36: note: previous definition is here
__attribute__((overloadable)) void foo(ulong a){}
                                   ^
overload.cl:6:36: error: redefinition of 'foo'
__attribute__((overloadable)) void foo(intptr_t a){}
                                   ^
overload.cl:5:36: note: previous definition is here
__attribute__((overloadable)) void foo(long a){}
                                   ^
overload.cl:8:36: error: redefinition of 'foo'
__attribute__((overloadable)) void foo(atomic_size_t a){}
                                   ^
overload.cl:7:36: note: previous definition is here
__attribute__((overloadable)) void foo(atomic_ulong a){}
                                   ^
overload.cl:10:36: error: redefinition of 'foo'
__attribute__((overloadable)) void foo(atomic_intptr_t a){}
                                   ^
overload.cl:9:36: note: previous definition is here
__attribute__((overloadable)) void foo(atomic_long a){}
                                   ^
4 errors generated.

I am wondering if this is a bug or expected behavior.

opencl-c.h has declarations of similar traits, e.g. some atomic builtin functions.

Thanks.

Sam

"size_t" is a typedef for one of "unsigned int", "unsigned long", or "unsigned long long" (depending on the target). So the error is expected.

-Eli

Is there any reason, then, to include explicit declarations of OpenCL atomic built-in functions on types atomic_size_t, atomic_intptr_t, atomic_uintptr_t and atomic_ptrdiff_t in opencl-c.h?

Brian

No, I can't think of any reason.

-Eli