[LLVMbugs] [Bug 16860] static const member is not a constant expression when accessed from reference with 'dot' operator and used as a template parameter

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Aug 11 15:34:13 PDT 2013


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

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> ---
This code is ill-formed.

int arr[rt.value]; is accepted because, as a GNU/C++14 extension, we accept
variable-length arrays ("arrays of runtime bound" in C++14 parlance) by
default. We'll reject that too if you build with -pedantic-errors.

'rt.value' is not a constant expression because the evaluation of 'rt' as an
lvalue is not permitted in a constant expression: a reference can only be used
in a constant expression if it is initialized by a constant expression (see
5.19/2). 't' is not a reference constant expression because it is an object of
automatic storage duration (see 5.19/4).

I sympathize here -- the code is certainly reasonable -- but gcc is wrong to
accept it. The natural way to allow this would be to weaken the requirement on
references from "initialized by a constant expression" to "initialized by a
core constant expression", but this code example alone doesn't seem like
sufficient justification for that.

-- 
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/20130811/bb0f5514/attachment.html>


More information about the llvm-bugs mailing list