[llvm-bugs] [Bug 31624] static method invocation via objects are not considered constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 12 17:42:47 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31624

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> ---
Nope, GCC and CL are wrong. [expr.const]/2.10:

"[An expression is not a constant expression if it would evaluate]  an
id-expression that refers to a variable or data member of reference type unless
the reference has a preceding initialization and either
— it is initialized with a constant expression or
— its lifetime began within the evaluation of e;"

Because the expression uses the name 'f' and that name cannot be evaluated, the
expression is not a constant expression. It doesn't matter that the callee is a
static function; evaluation of the LHS must succeed. Consider:

  (something with arbitrary non-constant side effects, f).hasBar()

This is obviously not constant.

-- 
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/20170113/c27506e8/attachment-0001.html>


More information about the llvm-bugs mailing list