[llvm-bugs] [Bug 34253] New: Constant expression from permitted result of a constant expression is not constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 21 02:48:55 PDT 2017


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

            Bug ID: 34253
           Summary: Constant expression from permitted result of a
                    constant expression is not constexpr
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: antoshkka at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The following code fails to compile:



int main() {
    static const char someVar[] = "str";
    constexpr auto c0 = someVar[0];
}



error: constexpr variable 'c0' must be initialized by a constant expression
    constexpr auto c0 = someVar[0];
                   ^    ~~~~~~~~~~



This seems to be an error:

"In any constexpr variable declaration, the full-expression of the
initialization shall be a constant expression [expr.const]"

Where [expr.const] has the paragraphs:

"A constant expression is either a glvalue core constant expression that refers
to an entity that is a permitted result of a constant expression <skip>

An entity is a permitted result of a constant expression if it is an object
with static storage duration that is either not a temporary object <skip>"

-- 
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/20170821/54057f2e/attachment.html>


More information about the llvm-bugs mailing list