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

Reducer callbacks trigger spurious -Wunneeded-internal-declaration warnings #154

Open
VoxSciurorum opened this issue Dec 20, 2022 · 1 comment · May be fixed by #228
Open

Reducer callbacks trigger spurious -Wunneeded-internal-declaration warnings #154

VoxSciurorum opened this issue Dec 20, 2022 · 1 comment · May be fixed by #228
Assignees
Labels
bug Something isn't working

Comments

@VoxSciurorum
Copy link
Contributor

The compiler incorrectly says static reducer callbacks used inside a template have not been emitted.

/* Unwanted warnings:

   unused.cpp:9:13: warning: function 'identity_64' is not needed and will not be emitted [-Wunneeded-internal-declaration]
   unused.cpp:13:13: warning: function 'sum_64' is not needed and will not be emitted [-Wunneeded-internal-declaration]
*/

#include <cilk/cilk.h>

static void identity_64(void *p) { *(long *)p = 0; }
static void sum_64(void *l, void *r) { *(long *)l += *(long *)r; }

template <class T>
T sum_cilk(){
  long cilk_reducer(identity_64, sum_64) sum = 0;
  return sum;
}

long f() {
  long total = sum_cilk<long>();
  return total;
}
@VoxSciurorum VoxSciurorum added the bug Something isn't working label Dec 20, 2022
@VoxSciurorum VoxSciurorum self-assigned this Dec 20, 2022
@neboat
Copy link
Collaborator

neboat commented Jun 28, 2024

It seems like this issue might be related to another issue that tools, such as clangd, don't handle the cilk_reducer keyword properly. Tthe problem stems from the fact that the cilk_reducer keyword and its arguments aren't really represented in the AST. Because most of clangd's functionality relies on the AST, this means that clangd fails to recognize the cilk_reducer keyword and its arguments. As a result, functions in modern IDEs, like VSCode, that use clangd don't work correctly with cilk_reducer.

It would be better to add a proper representation of cilk_reducer types to the AST, possibly based on how templated C++ types are represented in the AST. Such a change should fix clangds handling of cilk_reducer and may fix these spurious warnings as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants