[llvm-bugs] [Bug 48584] New: Reduction identifier "+" type requirements

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 23 07:27:58 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48584

            Bug ID: 48584
           Summary: Reduction identifier "+" type requirements
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dalg24 at gmail.com
                CC: a.bataev at hotmail.com, jdoerfert at anl.gov,
                    llvm-bugs at lists.llvm.org

The following code
```
#include <cstdio>

struct Point {
  int x;
  int y;
  Point& operator+=(Point const &other) { x += other.x; y += other.y; return
*this; }
};
void find_enclosing_rectangle ( int n, Point const* points )
{
  Point sump = {0, 0};
#pragma omp parallel for reduction(+: sump)
  for ( int i = 0; i < n; i++ ) {
     sump += points[i];
  }
  printf("sum = (%d, %d)\n", sump.x, sump.y);
}
```
yields `error: invalid operands to binary expression ('Point' and 'Point')`.

Reduction with “+” seems to require the binary plus operator but the OpemMP
specification
https://www.openmp.org/spec-html/5.1/openmpsu117.html#x152-1720002.21.5 (table
2.11) only mentions operator+=

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201223/545f61f5/attachment.html>


More information about the llvm-bugs mailing list