This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118f. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-07
(From submission #716.)
The following note added to 9.13.1 [dcl.attr.grammar] by issue 2695 embodies the design intent that attributes can be ignored by implementations:
[Note 5: The attributes specified in 9.13 [dcl.attr] have optional semantics: given a well-formed program, removing all instances of any one of those attributes results in a program whose set of possible executions (4.1.2 [intro.abstract]) for a given input is a subset of those of the original program for the same input, absent implementation-defined guarantees with respect to that attribute. -- end note]
However, the note is incorrect for attributes that contain a potentially-evaluated expression such as [[assume]] (9.13.3 [dcl.attr.assume]). For example,
template<int N>
struct reader {
friend auto flag(reader);
};
template<int N>
struct setter {
friend auto flag(reader<N>) {}
};
template<int N = 0, auto DifferenceMaker = [] {}>
consteval int next() {
if constexpr (requires { flag(reader<N>{}); }) {
return next<N + 1>();
} else {
(void) setter<N>{};
return N;
}
}
int main() {
static_assert(next() == 0);
[[assume(true || next())]];
static_assert(next() == 2);
}
While this particular example using stateful friend injection is addressed by issue 2118, similar examples can be constructed using mainstream facilities introduced by P2996R13 (Reflection); see the compile-time ticket counter example therein.
There are also counterexamples for [[no_unique_address]]; see issue 2866.
Forwarded to EWG with paper issue 2407, by decision of the CWG chair.