public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113579] New: GCC leaks memory inside when using statement expressions
@ 2024-01-24 11:43 usaxena95 at gmail dot com
2024-01-24 12:21 ` [Bug c++/113579] " rguenth at gcc dot gnu.org
2024-01-24 20:14 ` mpolacek at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: usaxena95 at gmail dot com @ 2024-01-24 11:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113579
Bug ID: 113579
Summary: GCC leaks memory inside when using statement
expressions
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: usaxena95 at gmail dot com
Target Milestone: ---
https://godbolt.org/z/dGT6K9a5e
#include <iostream>
struct Printy {
Printy(const char *name) : name(name) {
std::cout << "Printy(" << name << ")\n";
}
~Printy() { std::cout << "~Printy(" << name << ")\n"; }
const char *name;
};
int main() {
Printy arr[] = {Printy("a"), ({ // Printy is leaked.
Printy("b");
return {};
Printy("c");
})};
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/113579] GCC leaks memory inside when using statement expressions
2024-01-24 11:43 [Bug c++/113579] New: GCC leaks memory inside when using statement expressions usaxena95 at gmail dot com
@ 2024-01-24 12:21 ` rguenth at gcc dot gnu.org
2024-01-24 20:14 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-24 12:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113579
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think we somewhere document that control transfer into / out of stmt
expressions invokes undefined behavior.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/113579] GCC leaks memory inside when using statement expressions
2024-01-24 11:43 [Bug c++/113579] New: GCC leaks memory inside when using statement expressions usaxena95 at gmail dot com
2024-01-24 12:21 ` [Bug c++/113579] " rguenth at gcc dot gnu.org
@ 2024-01-24 20:14 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-24 20:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113579
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Right: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html says that
jumping into a ({}) is not okay; jumping out of it is okay only in certain
cases.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-24 20:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24 11:43 [Bug c++/113579] New: GCC leaks memory inside when using statement expressions usaxena95 at gmail dot com
2024-01-24 12:21 ` [Bug c++/113579] " rguenth at gcc dot gnu.org
2024-01-24 20:14 ` mpolacek 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).