Skip to content

clang++: abs of float vector comes out zero  #31

@kfjahnke

Description

@kfjahnke

clang++ (clang version 10.0.0-4ubuntu1) yields zero when abs() is called with a float vector. Here's code to reproduce the error:

#include <iostream>
#include <experimental/simd>

int main ( int argc , char * argv[] )
{
  std::experimental::simd
          < float ,
            std::experimental::simd_abi::fixed_size < 2 >
          > x ;

  x[0] = -1.0f ;
  x[1] =  1.0f ;

  auto y = abs ( x ) ;

  for ( int i = 0 ; i < 2 ; i++ )
  {
    std::cout << "x[" << i << "] : " << x[i] << " -> " ;
    std::cout << "y[" << i << "] : " << y[i] << std::endl ;
  }
}

Actual Results

compiling with clang I get the error:

$ clang++ -std=c++17 stdsimd_abs.cc
$ ./a.out
x[0] : -1 -> y[0] : 0
x[1] : 1 -> y[1] : 0

Expected Results

g++ yields the correct result.

$ g++ -std=c++17 stdsimd_abs.cc
$ ./a.out
x[0] : -1 -> y[0] : 1
x[1] : 1 -> y[1] : 1

Kay

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions