https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127021
Bug ID: 127021
Summary: Writing to volatile qualified std::nullptr_t should
not be valid in a constant expression
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: luigighiron at gmail dot com
Target Milestone: ---
The following code is incorrectly accepted by GCC:
consteval void foo(){
volatile decltype(nullptr)a=0;
a=0;
}
int main(){
foo();
}
Unlike with reading volatile qualified std::nullptr_t as in PR118661, writing
to an object with such a type does not have any exemption. Clang correctly
rejects this, MSVC and EDG also incorrectly accept this.