[LLVMbugs] [Bug 19643] accessing an element of `constexpr static array` inaccurately treated as ODR-usage

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 2 13:19:58 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19643

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |richard-llvm at metafoo.co.uk
         Resolution|---                         |INVALID

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
Sorry, that's not correct.

We have the expression A::a[0]. Let's walk through 3.2/3:

"A variable x [A::a] whose name appears as a potentially-evaluated expression
ex [the id-expression A::a, check] is odr-used unless

  applying the lvalue-to-rvalue conversion to x yields a constant expression
[it does]
  that does not invoke any non-trivial functions [it does not] and,
  if x is an object [it is],
    ex is an element of the set of potential results of an expression e, where
either the lvalue-to-rvalue conversion is applied to e, or e is a
discarded-value expression."

So: what possible values of 'e' are there? The set of potential results of an
expression is a set of subexpressions of the expression, so we only need to
consider expressions of which 'ex' is a subexpression. Those are:

  A::a
  A::a[0]

Of these, the lvalue-to-rvalue conversion is *not* applied immediately to A::a,
so we only consider A::a[0]. Per 3.2/2, the set of potential results of A::a[0]
is empty, so A::a is odr-used by this expression.


Now, you could argue that we first rewrite A::a[0] to *(A::a + 0). But that
changes nothing: the possible values of e are then

  A::a
  A::a + 0
  (A::a + 0)
  *(A::a + 0)

Of these, only the fourth has an lvalue-to-rvalue conversion applied to it, and
again, 3.2/2 says that the set of potential results of *(A::a + 0) is empty.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140502/2d8c0c86/attachment.html>


More information about the llvm-bugs mailing list