[cfe-dev] issue about overloading functions with size_t and ulong arguments

Liu, Yaxun (Sam) via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 15 11:37:52 PDT 2017


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 18134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170815/d8ca3063/attachment-0001.bin>


More information about the cfe-dev mailing list