llvm / llvm/llvm-project

attribute on member function type causes exception specification to be instantiated eagerly

Open
#185,109 6 comments 0 reactions 0 assignees View on GitHub
clang:frontend confirmed
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This fails to compile: https://godbolt.org/z/e7W7raqsf
```c++
template
class CRTP {
char* foo() & noexcept(noexcept(static_cast(nullptr)->bar()))
[[clang::lifetimebound]];
};
struct S : CRTP { char* bar(); };
```
However, if `[[clang::lifetimebound]]` is commented out, it compiles fine.

I'm not sure if the code is otherwise permitted to compile by the standard or not, but this prevents the usage of `lifetimebound` with `noexcept` and [CRTP](https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern), and feels like it should be avoidable.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure from the Godbolt example, then compare the behavior with [[clang::lifetimebound]] removed. Trace how the attribute on the member function interacts with the dependent noexcept expression and CRTP instantiation. Done means the reduced example no longer eagerly instantiates the exception specification when the attribute is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.