Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMD & reduction on signed types emits sign-conversion diagnostic #45304

Open
llvmbot opened this issue May 17, 2020 · 2 comments
Open

SIMD & reduction on signed types emits sign-conversion diagnostic #45304

llvmbot opened this issue May 17, 2020 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party openmp

Comments

@llvmbot
Copy link
Member

llvmbot commented May 17, 2020

Bugzilla Link 45959
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

With -Wsign-conversion, an & reduction on an integer value will emit a diagnostic. Here is a simple test case:

  int foo(int* v);

  int foo(int* v) {
    int r = ~0;

    #pragma omp simd reduction(&:r)
    for (int i = 0 ; i < 8 ; i++) {
      r &= v[i];
    }

    return r;
  }

When compiling:

  $ clang -Weverything -fopenmp-simd -c -o simd.o simd.c
  simd.c:6:32: warning: implicit conversion changes signedness: 'unsigned int' to 'int' [-Wsign-conversion]
    #pragma omp simd reduction(&:r)
                               ^
  1 warning generated.
@llvmbot
Copy link
Member Author

llvmbot commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#50798

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@mr-c
Copy link

mr-c commented Nov 6, 2023

I can confirm this still happens with clang-17

$ clang-17 -Weverything -fopenmp-simd -c -o simd.o llvm-45304.c 
llvm-45304.c:6:32: warning: implicit conversion changes signedness: 'unsigned int' to 'int' [-Wsign-conversion]
    6 |   #pragma omp simd reduction(&:r)
      |                                ^
llvm-45304.c:8:10: warning: unsafe buffer access [-Wunsafe-buffer-usage]
    8 |     r &= v[i];
      |          ^
2 warnings generated.
$ clang-17 --version
Debian clang version 17.0.4 (1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@Endilll Endilll added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party labels Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party openmp
Projects
None yet
Development

No branches or pull requests

3 participants