Re: GCC 4.0 Ada.Containers Cursor danger.
- From: "Dmitriy Anisimkov" <anisimkov@xxxxxxxxx>
- Date: 5 Jul 2005 10:11:10 -0700
> Container.Insert ("one", 1);
> Container.Insert ("two", 2);
> Container.Insert ("three", 3);
>
> > Table.Insert (Container, "two", 2222, Cursor, Success);
> > pragma Assert (not Success);
> >
> > -- Delete element "two" independently.
> >
> > Cursor2 := Table.Find (Container, "two");
> > Table.Delete (Container, Cursor2);
> >
> > -- The erroreneous line below do nothing and do not raise any
> > exception.
> >
> > Table.Replace_Element (Cursor, -22222);
>
> Well of course this is erroneous, since the element designated by
> Cursor was deleted in the previous statement!
Matthew,
I know that code have an error. I'm saying that the errors like this is
easy to create, and hard to find. Neither compiler not runtime check
for this errors. So, my point is trying to avoid using cursors, for
safety reasons. The Ada is designed to be safe language, Ada is a
hardly checking operations with access types, it is because we have
Unchecked_Deallocation and Unchecked_Access and Unrestricted_Access for
see, where could be danger. I do not see any "Unchecked_" operations
with a cursors. As I understand all cursors operations is "Unchecked_".
If i have to use cursors, i'm in the danger of errors like this. I'm
sure we could use containers without cursors. ADT doing it with
success.
I would propose to have a Ada.Containers subset without cursors for
safety reasons.
<<> valgrind showing the memory corruption
That's good, since what you did corrupts the memory.>>
Note that there is no way in Ada to currupt memory other then by
Unchecked_ or Unrestricted_ access operations. Ada.Containers introduce
a more "legal" way to do memory curruption. Why Java has so much
popularity. One of the reasons that there is absolutely no way to
currupt memory. I do not like Java for some reasons, but I hope Ada
would not be in the C "freedom" to currupt memory.
> The solution is simple: don't jump out of windows...
Where the "windows" safer in C or in Ada ?
.
- Follow-Ups:
- Re: GCC 4.0 Ada.Containers Cursor danger.
- From: Randy Brukardt
- Re: GCC 4.0 Ada.Containers Cursor danger.
- From: Dmitry A. Kazakov
- Re: GCC 4.0 Ada.Containers Cursor danger.
- From: Martin Dowie
- Re: GCC 4.0 Ada.Containers Cursor danger.
- From: Matthew Heaney
- Re: GCC 4.0 Ada.Containers Cursor danger.
- References:
- GCC 4.0 Ada.Containers Cursor danger.
- From: Dmitriy Anisimkov
- Re: GCC 4.0 Ada.Containers Cursor danger.
- From: Matthew Heaney
- GCC 4.0 Ada.Containers Cursor danger.
- Prev by Date: Re: A#
- Next by Date: Re: GCC 4.0 Ada.Containers Cursor danger.
- Previous by thread: Re: GCC 4.0 Ada.Containers Cursor danger.
- Next by thread: Re: GCC 4.0 Ada.Containers Cursor danger.
- Index(es):
Relevant Pages
|