llvm / llvm/llvm-project

erroneous nonblocking attribute warning with two layers of template functions

Open
#219,076 0 comments 0 reactions 0 assignees View on GitHub
clang:diagnostics
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

using clang 22.1.0 and `-Wfunction-effects`:

```cpp
template
int f1() noexcept [[clang::nonblocking]]
{
return 0;
}

template
auto f2(T a = f1()) noexcept [[clang::nonblocking]]
{
return a;
}

int main(int argc, char const* argv[])
{
return f2(argc);
}
```

```
nonblocking.cpp:8:32: warning: function with
'nonblocking' attribute must not call non-'nonblocking' expression
[-Wfunction-effects]
8 | auto f2(T a = f1()) noexcept [[clang::nonblocking]]
| ^
```

(also thinking that the warning message could be improved from its current triple-negative formulation: "NOT call NON-'NONblocking'")

Contributor guide

Open the contributing guide

Research direction

Start by compiling the supplied nonblocking.cpp reproducer with Clang 22.1.0 and -Wfunction-effects. Trace how the warning handles the default argument f1() across the two template functions. Done means the erroneous warning is resolved, with the diagnostic wording considered for clarity.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.