[PATCH] D28467: [Sema] Add warning for unused lambda captures

Malcolm Parsons via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 01:37:09 PST 2017

On 19 January 2017 at 03:47, Aaron Ballman <aaron.ballman at gmail.com> wrote:
> It is not used in an unevaluated context -- that is a bug.

It is an evaluated expression, but is it odr-used?

C++14 [basic.def.odr] p3:

A variable x whose name appears as a potentially-evaluated expression
ex is odr-used by ex unless applying the lvalue-to-rvalue conversion
(4.1) to x yields a constant expression (5.20) that does not invoke
any nontrivial functions and, if x is an object, ex is an element of
the set of potential results of an expression e, where either the
lvalue-to-rvalue conversion (4.1) is applied to e, or e is a
discarded-value expression (Clause 5). ...

5.20 [expr.const] p3:

An integral constant expression is an expression of integral or
unscoped enumeration type, implicitly converted to a prvalue, where
the converted expression is a core constant expression. [ Note: Such
expressions may be used as array bounds (8.3.4, 5.3.4), as bit-field
lengths (9.6), as enumerator initializers if the underlying type is
not fixed (7.2), and as alignments (7.6.2). — end note ]

I read that as kDelta is not odr-used.

GCC and ICC don't require kDelta to be captured either.

Malcolm Parsons

More information about the cfe-commits mailing list