llvm / llvm/llvm-project

decltype(auto) deduces a different type than decltype for captured C++ variables in Objective-C++ blocks

Open
#207,355 3 comments 0 reactions 0 assignees View on GitHub
clang:frontend objective-c++
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The following program fails to compile because the static_assert triggers (https://godbolt.org/z/59neq4a4a):

```objc++
template
inline constexpr bool is_same_as = false;

template
inline constexpr bool is_same_as = true;

struct X {};

void f() {
X x;

void (^b)(void) = ^{
decltype(auto) y = (x);
static_assert(is_same_as);
};
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Objective-C++ example from the issue in the linked Godbolt compiler explorer. Trace how decltype(auto) initialization and decltype handle the captured variable inside the block, then verify that the static_assert comparing decltype(y) with decltype((x)) passes without changing the reproducer's intended semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, objective-c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.