https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81911

            Bug ID: 81911
           Summary: Constant expression from permitted result of a
                    constant expression is not constexpr
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

The following code fails to compile:



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



error: the value of 'someVar' is not usable in 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>"

Reply via email to