[llvm-bugs] [Bug 42440] New: [Regression] nullptr_t lvalue-to-rvalue conversion bogusly constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 28 14:58:57 PDT 2019


            Bug ID: 42440
           Summary: [Regression] nullptr_t lvalue-to-rvalue conversion
                    bogusly constexpr
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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

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

(Clean compile)

<stdin>:2:24: error: constexpr variable 'p' must be initialized by a constant
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
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:
Selected GCC installation:
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

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/20190628/6f3508af/attachment.html>

More information about the llvm-bugs mailing list