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

Sumner, Brian via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 15 13:35:09 PDT 2017


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

-----Original Message-----
From: Friedman, Eli [mailto:efriedma at codeaurora.org] 
Sent: Tuesday, August 15, 2017 11:45 AM
To: Liu, Yaxun (Sam); cfe-dev (cfe-dev at lists.llvm.org); 'anastasia.stulova at arm.com'; Bader, Alexey (alexey.bader at intel.com)
Cc: Sumner, Brian
Subject: Re: [cfe-dev] issue about overloading functions with size_t and ulong arguments

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