public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101295] New: constexpr destructor: ''result_decl' not supported by dump_expr<expression error>' is not a constant expression
@ 2021-07-02 10:30 markus.kuehni at triviso dot ch
2023-04-13 17:37 ` [Bug c++/101295] " ppalka at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: markus.kuehni at triviso dot ch @ 2021-07-02 10:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101295
Bug ID: 101295
Summary: constexpr destructor: ''result_decl' not supported by
dump_expr<expression error>' is not a constant
expression
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: markus.kuehni at triviso dot ch
Target Milestone: ---
Trying to conceptualize a constexpr capable, optimizer friendly linked list
reference tracking smart pointer, I get this error:
<source>: In function 'int main()':
<source>:49:16: in 'constexpr' expansion of 'test()'
<source>:49:16: in 'constexpr' expansion of
'(&<anonymous>)->myptr<Obj>::~myptr()'
<source>:49:16: error: ''result_decl' not supported by dump_expr<expression
error>' is not a constant expression
49 | return test();
...
I'm not sure whether the code is standards compliant, but the error message is
broken anyway, it seems.
The same code works as I expect on clang, but creates an ICE on msvc. I tried
to create a minimal example that still shows the intention of the code.
https://godbolt.org/z/sod6oYE8T
```
// Minimized code of a linked list reference tracking smart pointer.
template<typename T>
struct myptr {
private:
T * p;
myptr * next;
public:
constexpr myptr(T * p) noexcept : p(p), next(p ? p->first : nullptr) {
if (p) {
p->first = this;
}
}
constexpr myptr(const myptr & other) noexcept : myptr(other.p) {}
constexpr ~myptr() noexcept {
if (p) {
myptr ** pnext = &(p->first);
while (*pnext != this) {
pnext = &((*pnext)->next);
}
*pnext = next;
next = nullptr;
if (!p->first) {
delete p;
}
p = nullptr;
}
}
};
struct Obj {
private:
struct myptr<Obj> * first{};
friend struct myptr<Obj>;
};
constexpr myptr<Obj> fun() {
myptr<Obj> obj(new Obj);
return obj;
}
// Force consteval to prove the myptr is constexpr capable.
consteval int test() {
fun();
return 42;
}
int main() {
return test();
}
```
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/101295] constexpr destructor: ''result_decl' not supported by dump_expr<expression error>' is not a constant expression
2021-07-02 10:30 [Bug c++/101295] New: constexpr destructor: ''result_decl' not supported by dump_expr<expression error>' is not a constant expression markus.kuehni at triviso dot ch
@ 2023-04-13 17:37 ` ppalka at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-04-13 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101295
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
Last reconfirmed| |2023-04-13
Known to fail| |10.4.0, 11.3.0, 12.2.0,
| |13.0
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-13 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 10:30 [Bug c++/101295] New: constexpr destructor: ''result_decl' not supported by dump_expr<expression error>' is not a constant expression markus.kuehni at triviso dot ch
2023-04-13 17:37 ` [Bug c++/101295] " ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).