Date: Wed, 17 Apr 2024 14:47:57 -0700
If you never use new/delete (or malloc/delete or many STL library features)
you have (mostly) avoided the heap.
> I was confusing tagged unions and classes,
There is nothing special about a tagged-unions that would use the heap (may
depend on what is in the union).
>i have to use virtual functions with classes to avoid the heap i believe?
sorry, non-sequitur. Apples and oranges. Different mechanisms with
different purposes.
If you are just trying to avoid the heap, use object pools or static
objects.
Maybe it would be better to understand what you are trying to solve and why.
Chris++;
On Wed, Apr 17, 2024 at 2:32 PM Richard Bamford <richardbamford1_at_[hidden]>
wrote:
> Thanks Chris!
>
> I was confusing tagged unions and classes, i have to use virtual functions
> with classes to avoid the heap i believe?
>
> Thank you!
> Richard B.
> ------------------------------
> *From:* Chris Ryan <chrisr98008_at_[hidden]>
> *Sent:* 17 April 2024 22:18
> *To:* std-discussion_at_[hidden] <std-discussion_at_[hidden]>
> *Cc:* Tiago Freire <tmiguelf_at_[hidden]>; Richard Bamford <
> richardbamford1_at_[hidden]>
> *Subject:* Re: [std-discussion] Safety critical C++ inheritance?
>
> A derived object is just an object, with the base object being the first
> thing in the object footprint. No allocation required. There are no
> special heap mechanisms involved.
>
> I believe the OP is confusing inheritance with dynamic-polymorphism that
> requires the base to provide the interface, using the virtual mechanism.
>
> You can use objects from multiple object pools (each pool of different
> object types, each object derived from the same base), or multiple
> static objects (each object derived from the same base), then be able to
> treat the objects polymorphically, using a base pointer. No
> allocation required.
>
> Chris++;
>
> On Wed, Apr 17, 2024 at 1:52 PM Tiago Freire via Std-Discussion <
> std-discussion_at_[hidden]> wrote:
>
> You can use the stack?
>
> Not sure I understand your question. As far as I know heap memory is not a
> requirement for inheritance.
>
>
>
> *From:* Std-Discussion <std-discussion-bounces_at_[hidden]> *On
> Behalf Of *Richard Bamford via Std-Discussion
> *Sent:* Wednesday, April 17, 2024 22:24
> *To:* std-discussion_at_[hidden]
> *Cc:* Richard Bamford <richardbamford1_at_[hidden]>
> *Subject:* [std-discussion] Safety critical C++ inheritance?
>
>
>
> Hi,
>
>
>
> The MISRA C++ programming standards and many safety critical applications
> are unable to use heap memory without filing deviations. Is there any way
> that programs aiming to follow those standards can use inheritance in C++
> without using heap memory?
>
>
>
> Thank you,
>
> Richard B.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
>
you have (mostly) avoided the heap.
> I was confusing tagged unions and classes,
There is nothing special about a tagged-unions that would use the heap (may
depend on what is in the union).
>i have to use virtual functions with classes to avoid the heap i believe?
sorry, non-sequitur. Apples and oranges. Different mechanisms with
different purposes.
If you are just trying to avoid the heap, use object pools or static
objects.
Maybe it would be better to understand what you are trying to solve and why.
Chris++;
On Wed, Apr 17, 2024 at 2:32 PM Richard Bamford <richardbamford1_at_[hidden]>
wrote:
> Thanks Chris!
>
> I was confusing tagged unions and classes, i have to use virtual functions
> with classes to avoid the heap i believe?
>
> Thank you!
> Richard B.
> ------------------------------
> *From:* Chris Ryan <chrisr98008_at_[hidden]>
> *Sent:* 17 April 2024 22:18
> *To:* std-discussion_at_[hidden] <std-discussion_at_[hidden]>
> *Cc:* Tiago Freire <tmiguelf_at_[hidden]>; Richard Bamford <
> richardbamford1_at_[hidden]>
> *Subject:* Re: [std-discussion] Safety critical C++ inheritance?
>
> A derived object is just an object, with the base object being the first
> thing in the object footprint. No allocation required. There are no
> special heap mechanisms involved.
>
> I believe the OP is confusing inheritance with dynamic-polymorphism that
> requires the base to provide the interface, using the virtual mechanism.
>
> You can use objects from multiple object pools (each pool of different
> object types, each object derived from the same base), or multiple
> static objects (each object derived from the same base), then be able to
> treat the objects polymorphically, using a base pointer. No
> allocation required.
>
> Chris++;
>
> On Wed, Apr 17, 2024 at 1:52 PM Tiago Freire via Std-Discussion <
> std-discussion_at_[hidden]> wrote:
>
> You can use the stack?
>
> Not sure I understand your question. As far as I know heap memory is not a
> requirement for inheritance.
>
>
>
> *From:* Std-Discussion <std-discussion-bounces_at_[hidden]> *On
> Behalf Of *Richard Bamford via Std-Discussion
> *Sent:* Wednesday, April 17, 2024 22:24
> *To:* std-discussion_at_[hidden]
> *Cc:* Richard Bamford <richardbamford1_at_[hidden]>
> *Subject:* [std-discussion] Safety critical C++ inheritance?
>
>
>
> Hi,
>
>
>
> The MISRA C++ programming standards and many safety critical applications
> are unable to use heap memory without filing deviations. Is there any way
> that programs aiming to follow those standards can use inheritance in C++
> without using heap memory?
>
>
>
> Thank you,
>
> Richard B.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
>
Received on 2024-04-17 21:48:10