Skip to content

[SYCL] C++ User-Literals Broken #2187

Closed
@ax3l

Description

@ax3l

Hi,

our code-base defines a C++ user-defined literal of the form

// myreal.H snippet
    using Real = float; // somewhere

    /** @{
      C++ user literals ``_rt`` &  ``_prt`` for short-hand notations
      Use this to properly add types to constant such as
      ```C++
      auto const mypi = 3.14_rt;
      auto const sphere_volume = 4_rt / 3_rt * pow(r, 3) * mypi;
      ```
    */
    constexpr Real
    operator"" _rt( long double x )
    {
        return Real( x );
    }

    constexpr Real
    operator"" _rt( unsigned long long int x )
    {
        return Real( x );
    }
    /// @}

prior to beta08 of oneAPI this worked quite well, but now it leads to a

dpcpp <...> -O3 -DNDEBUG -pthread -Wno-error=sycl-strict -fsycl -fsycl-unnamed-lambda -fsycl-device-code-split=per_kernel -o myfile.cpp.o -c myfile.cpp
myfile.cpp: error: 'operator""_rt' requires 128 bit size 'long double' type support, but device 'spir64-unknown-unknown-sycldevice' does not support it
    auto rand = 0.0_rt;
                   ^
myreal.H: note: 'operator""_rt' defined here
    operator"" _rt( long double x )

Specifically for C++ user-defined literals this is odd, since they are only defined with long double as floating point type:

Only the following parameter lists are allowed on literal operators : 
( const char * ) | (1) |  
( unsigned long long int ) | (2) |  
( long double ) | (3)
...

Overloading user-defined literals with double does not work:

myreal.H: error: invalid literal operator parameter type 'double', did you mean 'long double'?
    operator"" _rt( double x )
                    ^~~~~~~~~~~~~~~~~~~

Tried as a work-around -mlong-double-64, but this seems to have no effect (still reported as 128 bit).

Seen with beta08 on Ubuntu 18.04.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions