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

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 15 11:45:24 PDT 2017


On 8/15/2017 11:37 AM, Liu, Yaxun (Sam) via cfe-dev wrote:
> 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.
>

"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

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project




More information about the cfe-dev mailing list