[llvm-bugs] [Bug 28711] error: non-type template argument is not a constant expression (GCC compiles, clang doesn't)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 4 13:16:32 PDT 2016


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

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> ---
The expression "a.size()", used as a non-type template argument, is not a
constant expression, as Clang reports.

See [expr.const] (5.20)/2.10:

"A conditional-expression e is [not a constant expression if evaluating it]
would evaluate [...]:

2.10) an id-expression that refers to a variable or data member of reference
type unless the reference has a preceding initialization and either
2.10.1) it is initialized with a constant expression or
2.10.2) its lifetime began within the evaluation of e"

The id-expression "a" refers to a variable of reference type that is not
initialized (it's a function parameter) and whose lifetime began outside the
evaluation of e ("a.size()"). We can't determine which object is denoted by
"a", so the expression is non-constant (even though "size()" would not have
looked at that object).

-- 
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/20161004/8bc32441/attachment.html>


More information about the llvm-bugs mailing list