Re: Simple question, err... I think



* Jon Harrop:
Alf P. Steinbach wrote:
* Jon Harrop:
Doing so would violate the assumptions of this function.
One assumption is then that client code should leak memory.

Given that there's no deallocation for these RB trees, that's pretty
obvious.

You're using 'delete'. That's deallocation, opposite of "no deallocation". So, you're lying and/or extremely incompetent with regard to the matter under discussion.

Given that you have repeatedly demonstrated your C++ incompetence, the latter possibility cannot be dismissed out of hand.

In particular, there is a possibility that you have misunderstood (among other things...) the effect of 'delete' in C++ -- see comment at end.


Aha, we're getting nearer. Doesn't help with the other errors, unless they are
assumptions too -- are they? ROFLMAO.

The other errors were in your code.

Unsubstantiated and misleading: skip the rhetoric, please.


Such semantics are
no different from violating the assumptions of an iterator, for example.
Sorry, that's incorrect.

How do you believe the lack of safety in my function is different from that
in the STL?

Presumably you mean the C++ standard library.

The standard library containers are safe when used correctly.

Your function appears to be unsafe no matter how it's used -- memory can't be reclaimed without Undefined Behavior due to invalid pointer values -- and it also produces incorrect results. As demonstrated, it's a meaningless novice's attempt at coding. The C++ standard library, on the other hand, is usually implemented by experts, is fairly rigorously specified, and for any commonly used implementation, well tested, by hundreds of thousands up to millions of users.


This is an inherently unsafe language after all...
Sorry, that's incorrect.

e.g.:

"C and C++ are inherently unsafe" -
https://buildsecurityin.us-cert.gov/daisy/bsi/articles/best-practices/code/214.html?branch=1&language=1

This is well known.

I'm not going into a general language discussion with a newbie; let's stick to the concrete erronous code you posted.


whereas I think ditto that
you're expecting the original set structure to be abandoned.
Exactly. Implementations in GC'd languages just take care of this
themselves (persistence).
Sorry again, that's meaningless.

The OCaml I posted supports persistence. You can't do that in C++ without
writing or using a GC. There are two simple alternatives: in-place
modification or invalidation. I chose the latter.

That's so meaningless that it's not even wrong. First, persistence and GC are orthogonal concepts: one can be tied to the other in a given implementation, but that's about it (however, if my impression of you is correct, this is likely to spur you off on a tangent on how persistence can be coupled to to GC: don't, we're discussing your erronous code, not persistence). Second, you forgot to do the invalidation you claim.

Perhaps you labor under a misconception that 'delete' in C++ invalidates?

It does, but not in the sense that something can be detected as invalid afterwards: it destroys and deallocates, and does not change the pointer value -- which after this operation yields UB if used in any way.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.



Relevant Pages

  • Re: Simple question, err... I think
    ... One assumption is then that client code should leak memory. ... Given that there's no deallocation for these RB trees, ... a pointer to an invalid tree and it might segfault. ...
    (comp.programming)
  • Re: Simple question, err... I think
    ... Given that there's no deallocation for these RB trees, ... a pointer to an invalid tree and it might segfault. ... Your test code was the only source of invalid pointers. ...
    (comp.programming)
  • Re: Win2k machine wont recognize Win2k CD key
    ... | run Winnt32.exe from the Win2k installation CD. ... | I get this no matter what key I enter, and no matter which CD I use. ... | Any fix short of re-imaging the machine? ...
    (microsoft.public.win2000.registry)
  • Re: Sales calls from invalid CLI 02011510492
    ... As NTL don't seem bothered, could this matter be escaled to Ofcom as a ... Who says the CLI is invalid? ... eight digits, the first of which is a 1. ...
    (uk.telecom)
  • Re: Sarah Palin ridicules the research that helped in understanding autism
    ... Daily kos is hate filled bull shit. ... But it's invalid as a source. ... Doesn't matter which site picked it up and was pasted from. ...
    (rec.sport.pro-wrestling)