<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 - [Regression] nullptr_t lvalue-to-rvalue conversion bogusly constexpr"
   href="https://bugs.llvm.org/show_bug.cgi?id=42440">42440</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Regression] nullptr_t lvalue-to-rvalue conversion bogusly constexpr
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hstong@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This should not compile:
volatile decltype(nullptr) n;
extern constexpr void *p = n;

The type of the id-expression `n` is `volatile std::nullptr_t` prior to
lvalue-to-rvalue conversion. An lvalue-to-rvalue conversion occurs before we
get a null pointer constant.

N4820 subclause 7.7 [expr.const] paragraph 4, bullet 4.7 prohibits such an
lvalue-to-rvalue conversion during constant expression evaluation.

Recent comments in this area include r363429, "PR23833, DR2140: an
lvalue-to-rvalue conversion on a glvalue of type nullptr_t does not access
memory".

### COMPILE COMMAND:
clang++ -std=c++2a -Wall -Wextra -pedantic-errors -o /dev/null -c -xc++ -


### ACTUAL OUTPUT:
(Clean compile)


### EXPECTED OUTPUT:
<stdin>:2:24: error: constexpr variable 'p' must be initialized by a constant
expression
extern constexpr void *p = n;
                       ^   ~
<stdin>:2:28: note: read of volatile-qualified type 'volatile
decltype(nullptr)' (aka 'volatile nullptr_t') is not allowed in a constant
expression
extern constexpr void *p = n;
                           ^
1 error generated.


### COMPILER VERSION INFO (clang++ -v):
clang version 9.0.0 (trunk 364614)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
Found candidate GCC installation:
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0
Selected GCC installation:
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64</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>