* how to figure out if an instance was created on the "stack" or on the "heap"
@ 2020-07-24 20:00 aotto
2020-07-24 21:29 ` Dan Kegel
0 siblings, 1 reply; 2+ messages in thread
From: aotto @ 2020-07-24 20:00 UTC (permalink / raw)
To: gcc-help
Hi,
a C++ class can be created on the "stack" or on the "heap"
class A {
int test;
}
// stack
A myA();
// heap
A* myA = new A();
Question:
it is possible (with gcc) to find out if a instance was created on a
"stack" or on a "heap" *
mfg
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: how to figure out if an instance was created on the "stack" or on the "heap"
2020-07-24 20:00 how to figure out if an instance was created on the "stack" or on the "heap" aotto
@ 2020-07-24 21:29 ` Dan Kegel
0 siblings, 0 replies; 2+ messages in thread
From: Dan Kegel @ 2020-07-24 21:29 UTC (permalink / raw)
To: aotto; +Cc: gcc-help
https://man7.org/linux/man-pages/man3/end.3.html may be of interest, if
you're running on Linux.
But objects can also be static, and there are alternate stacks, so this
might be more complicated than it sounds.
Why do you need to know?
On Fri, Jul 24, 2020, 13:00 aotto <aotto1968@t-online.de> wrote:
> Hi,
>
> a C++ class can be created on the "stack" or on the "heap"
>
> class A {
> int test;
> }
>
> // stack
> A myA();
>
> // heap
> A* myA = new A();
>
>
> Question:
>
> it is possible (with gcc) to find out if a instance was created on a
> "stack" or on a "heap" *
>
>
> mfg
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-24 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 20:00 how to figure out if an instance was created on the "stack" or on the "heap" aotto
2020-07-24 21:29 ` Dan Kegel
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).