<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Not a constant expression: comparison between unequal pointers to void has unspecified result"
   href="https://bugs.llvm.org/show_bug.cgi?id=46308">46308</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Not a constant expression: comparison between unequal pointers to void has unspecified result
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Keywords</th>
          <td>compile-fail
          </td>
        </tr>

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

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

        <tr>
          <th>Component</th>
          <td>C++14
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>language.lawyer@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>About the following program:


struct S
{
        int i;
        int j;
};

constexpr S s {};

static_assert(&s.i < (void*)&s.j);



clang in C++14, C++17 and C++2a modes says that the expression in static_assert
is not a constant expression:

$ clang++ prog.cc -std=c++14
prog.cc:9:15: error: static_assert expression is not an integral constant
expression
static_assert(&s.i < (void*)&s.j, "");
              ^~~~~~~~~~~~~~~~~~
prog.cc:9:20: note: comparison between unequal pointers to void has unspecified
result
static_assert(&s.i < (void*)&s.j, "");
                   ^

(<a href="https://wandbox.org/permlink/IXwrV0M75To3wUUB">https://wandbox.org/permlink/IXwrV0M75To3wUUB</a>)

However, the special handling of pointers to void has been removed from
[expr.rel] by <a href="http://wg21.link/n3624">http://wg21.link/n3624</a> (applied in [1]), so the result of
comparing unequal pointers to void is no longer unspecified, so the expression
is a constant expression.



[1]
<a href="https://github.com/cplusplus/draft/commit/89281b5795f47b9196c37ce8008b4873a76e90ef#diff-64a673ab7a20068092a4cf86b36f4334L3647-L3650">https://github.com/cplusplus/draft/commit/89281b5795f47b9196c37ce8008b4873a76e90ef#diff-64a673ab7a20068092a4cf86b36f4334L3647-L3650</a></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>