<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang incorrectly rejects constexpr constructor which modified member variable in its body"
   href="http://llvm.org/bugs/show_bug.cgi?id=19741">19741</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang incorrectly rejects constexpr constructor which modified member variable in its body
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++1y
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ytj000@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>struct A {
        int a = 0;
        constexpr A() { a = 1; }
    };

    constexpr bool f() {
        constexpr A a;
        static_assert(a.a == 1, ""); // L1: OK
        return a.a == 1;
    }
    static_assert(f(), ""); // L2: Error, can not modify A::a in constexpr

- Online Compiler URL: <a href="http://goo.gl/jni6Em">http://goo.gl/jni6Em</a>
- Compiler: clang 3.4 (with -std=c++1y)
- System: Linux 3.2


The constructor satisfies all the conditions listed in ยง7.1.5/4 of N3936.
However, clang complains:

clang++ -stdlib=libc++ -std=c++1y a.cpp -c -o a.o -Wall
a.cpp:11:15: error: static_assert expression is not an integral constant
expression
static_assert(f(), ""); // L2: Error
              ^~~
a.cpp:3:23: note: modification of object of const-qualified type 'const int' is
not allowed in a constant expression
    constexpr A() { a = 1; }
                      ^
a.cpp:7:17: note: in call to 'A()'
    constexpr A a;
                ^
a.cpp:11:15: note: in call to 'f()'
static_assert(f(), ""); // L2: Error
              ^
1 error generated.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>