Bug 102220 - Conversion from cv void* to object-type* not rejected during constant evaluation
Summary: Conversion from cv void* to object-type* not rejected during constant evaluation
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2021-09-06 16:51 UTC by Johel Ernesto Guerrero Peña
Modified: 2022-01-17 11:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-09-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johel Ernesto Guerrero Peña 2021-09-06 16:51:42 UTC
See https://godbolt.org/z/ecYjGsWo7.
```C++
#include <cassert>
int main() {
  [i=0]() consteval /*mutable*/ {
    ++*(int*)(void*)&i;
    assert(i == 1);
  }();
}
```

A minimal reproduction:
```C++
int main() {
  [i=0]() consteval {
    (void)+*(const int*)(const void*)&i;
  }();
}
```

Discovered at https://cpplang.slack.com/archives/C263VAF2B/p1630942490163700?thread_ts=1630937296.159200&cid=C263VAF2B.
Comment 1 Andrew Pinski 2021-09-09 00:08:43 UTC
Confirmed.