https://bugs.llvm.org/show_bug.cgi?id=42440
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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
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
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs