Is the vptr at the beginning of an object?

A

Alf P. Steinbach

* DaveB:
Bo said:
DaveB said:
James Kanze wrote:
* red floyd:
On 4/2/2010 2:12 PM, DaveB wrote:
[insult to a member of the Committee redacted]
*PLONK*
Well, there was a bit of insult, true.
On the other hand, I fail to see what James' state as a member
of the standardization committee has to do with anything.
I don't think it does (especially since I haven't been
particularly active lately). On the other hand, calling an
accurate and precise description of the issues "technical
gibberish" gives a very good idea of the competence (technical
and otherwise) of the poster. One gets the feeling that he
prefers to ignore real issues.
The question remains open. Maybe someone NOT in the priesthood of
technobabblery can answer it.
I think we have already seen the answer:

In some cases it might be that a vptr is the first member of an
object. The only exception is when it is not, or when there isn't
exactly one vptr in the object.

I didn't see that one, and it points the direction to the answer I was
looking for. I was looking for someone who knows about a number of
"mainstream" compilers and can expound on the implementations of vptrs in
those. The assumption, or hope, being that "all" compilers use vptrs
rather than some other way. I asked more generally than I needed to know,
but the added information from someone who had it was easy enough to ask
for. Particularly, though, I wanted to know about gcc because between
that and VC, I my target platform is covered by those 2, and I am using
PLATFORM loosely here. I don't use multiple inheritance and am not
worried about anything strange happening in some remote corner case, and
if I was, I would have given more information than just "where is that
dang vptr!?". What I am doing that makes me need that information is not
relevant, and none of anyone's business unless I volunteer it. For
someone (not you in this post) to say that the question has been finely
answered, while I still have not the information I solicited, is pompous,
or at least seems so with a high degree of certainty, not to let a
sleeping dog alone, of course.

What the real problem is, is relevant, believe or not.

For example, if you're trying to reinvent COM or XCOM, then you can leverage the
guarantees that the compilers that support COM provide. It's slightly off topic
in this group but hey. No problem, except that going into details about that
would be ungood if that's not what you're trying to do.

For another example, if you're trying to somehow dynamically change an object's
type, then we can suggest less braindead alternatives. Yes, it's braindead. I've
actually worked with people who tried that, although it was in Visual Basic.
They also did other very braindead things, such as one DLL per class, with lots
and lots of classes. Of course they only asked me for help *after* they'd done
these silly things, when the consequences had really started to bite them.


Cheers & hth.,

- Alf
 
D

DaveB

Alf P. Steinbach said:
* DaveB:
Bo said:
DaveB wrote:
James Kanze wrote:
* red floyd:
On 4/2/2010 2:12 PM, DaveB wrote:
[insult to a member of the Committee redacted]
*PLONK*
Well, there was a bit of insult, true.
On the other hand, I fail to see what James' state as a member
of the standardization committee has to do with anything.
I don't think it does (especially since I haven't been
particularly active lately). On the other hand, calling an
accurate and precise description of the issues "technical
gibberish" gives a very good idea of the competence (technical
and otherwise) of the poster. One gets the feeling that he
prefers to ignore real issues.
The question remains open. Maybe someone NOT in the priesthood of
technobabblery can answer it.
I think we have already seen the answer:

In some cases it might be that a vptr is the first member of an
object. The only exception is when it is not, or when there isn't
exactly one vptr in the object.

I didn't see that one, and it points the direction to the answer I was
looking for. I was looking for someone who knows about a number of
"mainstream" compilers and can expound on the implementations of vptrs
in those. The assumption, or hope, being that "all" compilers use
vptrs rather than some other way. I asked more generally than I needed
to know, but the added information from someone who had it was easy
enough to ask for. Particularly, though, I wanted to know about gcc
because between that and VC, I my target platform is covered by those
2, and I am using PLATFORM loosely here. I don't use multiple
inheritance and am not worried about anything strange happening in
some remote corner case, and if I was, I would have given more
information than just "where is that dang vptr!?". What I am doing
that makes me need that information is not relevant, and none of
anyone's business unless I volunteer it. For someone (not you in this
post) to say that the question has been finely answered, while I still
have not the information I solicited, is pompous, or at least seems so
with a high degree of certainty, not to let a sleeping dog alone, of
course.

What the real problem is, is relevant, believe or not.

Another, and again, posting outside of the scope of the question. "Why
so, how to for"?! Do you know what "scope" means? No offense meant if you
don't know that, or the little that I do. I didn't ask for brain-dumps of
anyone's experience or realm of knowledge. I asked a specific question.
If anyone tries to add "more" or "other", well then we have what is now:
an unanswered question.
 
I

Ian Collins

Another, and again, posting outside of the scope of the question.

Then why don't you ask on a group or forum where it would get an
appropriate answer? You mention gcc and VC, they both have their own
groups.
 
P

Peter Remmers

Am 02.04.2010 23:12, schrieb DaveB:
Techno gibberish. I asked about common practice, not hypothetical theory,
and it doesn't take anyone with one ioda of intuition to assume that I
was talking about the simple case. Use of this forum to spout
technobabble at any/every opportunity, is annoying at best. (If you can't
help it because you are a nerd, then I apologize for not being cognitive
of the affliction, and hope you get the help you need).

I agree.

James wasn't able to come down from his noble steed and answer a simple
question. It is my obervation from reading this ng for quite some time
that this newsgroup is inhabitated by people who tend to indoctrinate
the casual poster without themselves having any clue about the
question's or the questioner's background. I use the word "indoctrinate"
in order to avoid using the word "smartass". It is all too tempting when
you are an "expert" to react with arrogance and presumtuousness to a
"non-expert" question.

I agree, and I have made the experience myself, that many questions
arise from problems that people would not have if they hadn't made a bad
decision at some earlier point, i.e. they are trying to tackle the
problem from the wrong side. You can see from the question that they are
on the wrong track, and the best way to help them is to point out some
root cause, which quite often has yet to be wormed out of them. I agree
that sometines the devil is in the detail, and I'm a perfectionist
myself who gets lost in the details all too often.

But it is just wrong alienate people by answering "who cares?", or "you
shouldn't be asking this question". Maybe there's a reason that you
don't see at first. Maybe it is just pure curiosity, which, if nothing
else, makes it a perfectly legitimate question (for an example, see Paul
N's post).

Even though James' answer does have a technical correctness to it, it is
actually avoiding the question by moving to a different level. The
question was "In practice, ...", and this can very well be answered with
an "In practice, ..." answer. It was very evident that the questioner
knows this is an implementation detail, and portable code should not
depend on it. Maybe even platform dependent code should not rely on it,
and there may be better ways. But, again, you don't know the intentions,
so drawing premature conclusions is inappropriate. Maybe answering the
question and *then* adding "... but what exactly is it that you want to
do?" would come across in a completely different light.

Maybe this question is compiler specific and should be asked in a
compiler specific newsgroup. Maybe the "across most compilers" part has
made it ok to be posted here. I'm sure this would not have been the
first time implementation details were discussed here.

Maybe James is a committee member. Maybe this should not have anything
to do with the way he answered the question, or the way the answer may
be taken.

Maybe Dave's reaction to James' answer was a bit harsh. Maybe he does
have a point.

So much for my two cents.

Regards,
Peter
 
J

Joshua Maurice

James said:
* red floyd:
On 4/2/2010 2:12 PM, DaveB wrote:
[insult to a member of the Committee redacted]
*PLONK*
Well, there was a bit of insult, true.
On the other hand, I fail to see what James' state as a member
of the standardization committee has to do with anything.
I don't think it does (especially since I haven't been
particularly active lately).  On the other hand, calling an
accurate and precise description of the issues "technical
gibberish" gives a very good idea of the competence (technical
and otherwise) of the poster.  One gets the feeling that he
prefers to ignore real issues.

The question remains open. Maybe someone NOT in the priesthood of
technobabblery can answer it.

Maybe you could pull your head out of your ass and listen. Your
question does not make sense, even if you're adding on "for most
commercial compilers in common use". All commercial C++ compilers
support multiple inheritance and virtual inheritance. Some object in
such a hierarchy may will multiple vptrs. Your question was "Is the
vptr always at offset 0 of the object?" My answer is the question
"Which vptr?"

Finally, perhaps you could explain the problem you're trying to solve.
That would significantly help us give you useful answers.
 
J

Joshua Maurice

Even though James' answer does have a technical correctness to it, it is
actually avoiding the question by moving to a different level. The
question was "In practice, ...", and this can very well be answered with
an "In practice, ..." answer. It was very evident that the questioner
knows this is an implementation detail, and portable code should not
depend on it. Maybe even platform dependent code should not rely on it,
and there may be better ways.

It is evident that he does not know what he's talking about, as he
does not know there can be multiple vptrs per object.
But, again, you don't know the intentions,
so drawing premature conclusions is inappropriate. Maybe answering the
question and *then* adding "... but what exactly is it that you want to
do?" would come across in a completely different light.

As he does not know what he's talking about, James gave the standard
line: "You probably don't need to do this, nor want to do this, nor
can do this portably. What are you trying to do? Perhaps there's a
sane way to do it without relying upon an implementation detail."

If he was simply asking about the implementation detail to learn about
the C++ language (which is a good thing), then that's a different
story. In which case, the answer is: "It doesn't matter. It could be
always at the start (for a single vptr per object), or whereever the
compiler feels like putting it. It does not affect the algorithm in
any meaningful way, though it will affect binary compatibility if the
compiler were to change where it put it, or if a base class, direct or
indirect, was added or removed, etc. etc. for anything that can break C
++ binary compatibility. As a practical matter, the compiler probably
puts the vptr at offset 0 for the simple cases, and has a more complex
solution for multiple and virtual inheritance."
 
J

James Kanze

Am 02.04.2010 23:12, schrieb DaveB:
I agree.

James wasn't able to come down from his noble steed and answer
a simple question.

Excuse me, but I did answer the question. The fact that the
correct answer to the question (i.e. the facts) doesn't happen
to please the original poster is a different issue; I can't do
anything about that, since the facts aren't likely to change.

[...]
Maybe this question is compiler specific and should be asked
in a compiler specific newsgroup.

It's not that compiler specific, since every compiler I know
does use multiple vptr, and none makes any guarantee with
regards to where the vptrs will be in the object.
 
P

Peter Remmers

Am 06.04.2010 01:06, schrieb James Kanze:
Excuse me, but I did answer the question.

Excuse me, but no, you didn't answer the question. You avoided the
question and came with a blunt answer.

Answering a question for internal workings with "none of your business"
is just silly. You could always say that one need not know the internal
specifics of a walkman, a watch, a record player, you-name-it, in order
to use them. Yet as a kid I disassembled such things to see how they
work. Asking how things work is a valid question that can always be
answered by explaining the details. I wouldn't accept "who cares" as an
answer. Your insisting on the "fact" that such a question must not be
asked just shows how narrow-minded you are.
> The fact that the
> correct answer to the question (i.e. the facts) doesn't happen
> to please the original poster is a different issue; I can't do
> anything about that, since the facts aren't likely to change.

The fact (and I don't use quotes here because I agree) that one does not
need to know about vtable layout to write good software in C++ is not
equal to the "fact" that one must not, for whatever reason, be
interested in such details, and it does not justify avoiding the
question and claiming this is the only correct answer. Again, I must
point out that we still don't know anything about Dave's reasons for
asking. And even if he intends to use this knowledge to write platform
and compiler dependent code this does not justify the attitude you are
showing.

If your anwer is "who cares", it's not that you can't answer the
question at the expected level (because I'm sure you could), it's that
you don't *want* to answer it. And I agree that if you only have your
"who cares" to contribute, you really shouldn't have bothered posting.
In the end this attitude just shows that you are trying to indoctrinate
people, and, please, spare us your education.

It's the same kind of education that people show when they drive on the
highway on the leftmost lane at the exact speed limit only to prevent
others from driving faster.

Regards,
Peter
 
P

Peter Remmers

Am 06.04.2010 00:23, schrieb Joshua Maurice:
It is evident that he does not know what he's talking about, as he
does not know there can be multiple vptrs per object.

How can you tell? I am sure he knows this.
As he does not know what he's talking about, James gave the standard
line: "You probably don't need to do this, nor want to do this, nor
can do this portably. What are you trying to do? Perhaps there's a
sane way to do it without relying upon an implementation detail."

If James had used this exact wording, it would not have come across as
arrogant as it did, although this does not answer the question.
If he was simply asking about the implementation detail to learn about
the C++ language (which is a good thing), then that's a different
story.

How can you tell that he did not? And even if you don't agree with the
reasons, how can you be so presumptuous and judge that he is not worth
getting a decent answer to his question?
> In which case, the answer is: "It doesn't matter. It could be
always at the start (for a single vptr per object), or whereever the
compiler feels like putting it. It does not affect the algorithm in
any meaningful way, though it will affect binary compatibility if the
compiler were to change where it put it, or if a base class, direct or
indirect, was added or removed, etc. etc. for anything that can break C
++ binary compatibility.

Blah blah. I'm sure the poster knew all of this. I know that I do, and
yet I can imagine asking the OP's question.
> As a practical matter, the compiler probably
puts the vptr at offset 0 for the simple cases, and has a more complex
solution for multiple and virtual inheritance."

Here we go. Why, oh why, is it so hard to just answer the question at
the level it was asked, and instead go on beating around the bush,
trying to educate people? As I wrote in my first post, you can always go
on questioning the reasons *afterwards*.

Regards,
Peter
 
J

Joshua Maurice

Am 06.04.2010 00:23, schrieb Joshua Maurice:

Blah blah. I'm sure the poster knew all of this. I know that I do, and
yet I can imagine asking the OP's question.

Really? So you would ask a question which implies a falsehood? The
question went "At what offset is the vptr located?" This implies that
there is at most a single vptr per object, which is false. Thus the
question is nonsensical.

The OP basically replied with "Obviously, I'm talking only about the
simple case." My reply would have been something along the lines of
"Obviously, the dog is on fire." (Slashdot humor.)

Here we go. Why, oh why, is it so hard to just answer the question at
the level it was asked, and instead go on beating around the bush,
trying to educate people? As I wrote in my first post, you can always go
on questioning the reasons *afterwards*.

Exactly what am I supposed to be doing if not "educating people" when
answering questions posted to a newsgroup? I'm confused. Communication
is more than simply relating words verbatim. Discussion by its very
nature is the transfer of information, aka education. Perhaps you mean
some specific colloquialism of "education", perhaps meaning "to
patronize" or something similar. In that case, James and myself were
not being patronizing.

Again as a practical matter, when I hear people ask questions like
"what offset is the vptr at?", simply answering the question does the
group and the person a disservice. It may suggest that it's reasonable
to use this knowledge when it's not. While this knowledge is not
"evil", it has no practical or educational benefit, and simply
offering it up will probably do more harm than good for a prospective C
++ programmer.

And it's not beating around the bush. Beating around the bush would be
saying "It's probably at offset 0 for simple cases, and it depends on
the implementation for multiple and/or virtual inheritance situations.
However, you shouldn't rely on that, and the exact offset doesn't
matter for comprehension of the compilation process."

The concise form (the opposite of "beating around the bush") is
"Doesn't matter. You cannot rely on a particular offset in practice,
and the compilation process is basically the same irrelevant of the
offset for the simple case."
 
K

Kai-Uwe Bux

Joshua Maurice wrote:

[...]
Again as a practical matter, when I hear people ask questions like
"what offset is the vptr at?", simply answering the question does the
group and the person a disservice.
[...]

True, but the alternative is not between "simply" answering the question and
providing the technical background. What was suggested is answering the
question _and_ providing background information (such as: (a) any program
relying on that knowledge invokes undefined behavior, (b) there is trouble
with multiple inheritance, (c) there need not be a vptr at all, (d) there
might not be a _common_ practice of where vptrs are, ...). Choosing to
_only_ provide that additional information and brushing off the interest in
the original question with "who cares" could legitimately be viewed as rude
or patronizing.


Best

Kai-Uwe Bux
 
P

Peter Remmers

Am 06.04.2010 14:27, schrieb Joshua Maurice:
Really? So you would ask a question which implies a falsehood? The
question went "At what offset is the vptr located?" This implies that
there is at most a single vptr per object, which is false. Thus the
question is nonsensical.

I agree that saying *the* vptr implies there's only one. But that does
not make it nonsensical. The way I see it is that multiple inheritance
is not widely used and is even regarded by some as a questionable
feature of the C++ language which only complicates things and which has
therefore been omitted in other languages such as Java. So assuming
single inheritance and thus a single vptr is not that far-fetched. You
could also deduce "ok, he talks about *the* vptr, so he must mean the
single inheritance case". Assuming from this that the OP does not know
about MI is going a step too far. His reaction, which you quote below,
only reflects this.

Deducing from the question that the OP "doesn't know what he's talking
about" is presumptuous. It means that without further indication you
assume people are incompetent. Which in turn means you are arrogant.

"To weigh the words" and "to split hairs" is an inherent problem in this
newsgroup. Everyone clings to the specification and is immediately upset
or feels compelled to comment with correction if something is not
explicitly or clearly stated, or is not using the-one-and-only correct term.

For scientific work, discipline and well-defined terms are essential,
but unfortunately it is too easy to exaggerate and to fall into the
word-weighing and hair-splitting trap, spiced up with arrogance and
patronism. I know I've fallen into the same trap numerous times.
The OP basically replied with "Obviously, I'm talking only about the
simple case." My reply would have been something along the lines of
"Obviously, the dog is on fire." (Slashdot humor.)



Exactly what am I supposed to be doing if not "educating people" when
answering questions posted to a newsgroup? I'm confused. Communication
is more than simply relating words verbatim. Discussion by its very
nature is the transfer of information, aka education. Perhaps you mean
some specific colloquialism of "education", perhaps meaning "to
patronize" or something similar. In that case, James and myself were
not being patronizing.

That is actually a pretty good word. (The german word I would use is
"belehren")
Again as a practical matter, when I hear people ask questions like
"what offset is the vptr at?", simply answering the question does the
group and the person a disservice.

That is your judgement.
It may suggest that it's reasonable
to use this knowledge when it's not. While this knowledge is not
"evil", it has no practical or educational benefit, and simply
offering it up will probably do more harm than good for a prospective C
++ programmer.

Again, that is your judgement. You decide that you should actively hold
back this information *even if* asked for exactly this information.
Information in itself is not evil. I agree that care must be taken not
to rely on things that should not be relied on. But you can always
explain that one must be careful. Actively refusing to answer a question
is not the solution. And besides, you cannot prevent others from posting
and giving away the information.

You take the right to judge that this information is "too dangerous" or
something to be just told here. You go on and tell other people in their
face that they don't know what they are talking about and that therefore
they don't qualify to receive the requested knowledge.

You don't *offer* advice, you *force* it on others. That *is* indeed
patronizing and in my opinion extremely disrespectful.
And it's not beating around the bush. Beating around the bush would be
saying "It's probably at offset 0 for simple cases, and it depends on
the implementation for multiple and/or virtual inheritance situations.
However, you shouldn't rely on that, and the exact offset doesn't
matter for comprehension of the compilation process."

The concise form (the opposite of "beating around the bush") is
"Doesn't matter. You cannot rely on a particular offset in practice,
and the compilation process is basically the same irrelevant of the
offset for the simple case."

Ok, I'm not native english, so excuse me if some expressions I had to
look up don't have the intended connotations. With "beating around the
bush" I meant "not getting to the point", which is what avoiding the
straight answer does.

Regards,
Peter
 
Ö

Öö Tiib

Answering a question for internal workings with "none of your business"
is just silly.

You read "who cares" as "You should not care" or even "none of Your
business" ... I read it "I don't care". Latter is closer on common
case ... people usually talk about themselves and not about others. In
any case "who cares" does not mean that "stop reading", since he
further explained why worrying about it has no value.

As for rest of that Jameses answer ... this time it was quite
practical in sense that it was not about exotic platforms that he has
had luck to touch or hypotetical implementations that may be possible
by standard. Quite common classes compiled on the most popular
compilers produce instances that have 0 vtables, 1 vtable or n
vtables. When at least one vtable is present then it may be at
position 0 in instance data and may not be. So that question did not
make sense without further narrowing the situation.

OP had of course correct intuition that vtable is not placed
randomly ... but for specific vtable positioning patterns for specific
compilers with specific compilation options and specific class
hierarchy it was perhaps asked in wrong newsgroup. So when I was young
and clueless ... I was not overly cocky about it. ;)
 
J

James Kanze

Am 06.04.2010 01:06, schrieb James Kanze:
Excuse me, but no, you didn't answer the question. You avoided
the question and came with a blunt answer.

No. I gave the only correct answer possible. The question has
no meaning, there's nothing you can do with a purported
answer, and it's something you really don't need or want to
know.
Answering a question for internal workings with "none of your
business" is just silly.

I didn't say "none of your business".

There are two issues: the technical content and the style. With
regards to the technical content, my answer remains the only
possible correct answer. As for the style, I adopt that to the
milieu. In news groups, answers are short and to the point.
You could always say that one need not know the internal
specifics of a walkman, a watch, a record player, you-name-it,
in order to use them. Yet as a kid I disassembled such things
to see how they work. Asking how things work is a valid
question that can always be answered by explaining the
details. I wouldn't accept "who cares" as an answer. Your
insisting on the "fact" that such a question must not be asked
just shows how narrow-minded you are.

That's a different question, and in the past, I've explained how
compilers implement virtual functions. The original poster,
however, seems to already be aware of how virtual functions were
implemented. The question didn't concern the mechanics of the
issue.
The fact (and I don't use quotes here because I agree) that
one does not need to know about vtable layout to write good
software in C++ is not equal to the "fact" that one must not,
for whatever reason, be interested in such details, and it
does not justify avoiding the question and claiming this is
the only correct answer.

Read the question again. He didn't ask about the mechanisms
used to implement virtual functions. I can quite understand a
programmer being curious about that, if he doesn't know it.
 
P

Peter Remmers

Am 07.04.2010 00:34, schrieb James Kanze:
No. I gave the only correct answer possible.

So you still insist that questioning the question itself is the only
correct answer. I assert that the term "correct" does not apply here.
The question has
no meaning, there's nothing you can do with a purported
answer, and it's something you really don't need or want to
know.

That is your judgement. And who are you to judge what others are allowed
to want to know and what not? There *is* a decent answer to this
question, and even if the answer was "there is no common practice across
compilers", it is in any case more of an answer to the question than
just denying the validity of the question.
I didn't say "none of your business".

It amounts to the same. It means "I don't want you to know, and I'm
taking the effort of posting a reply to tell you just that." Which leads
us back to the statement that you should rather not have bothered posting.
There are two issues: the technical content and the style. With
regards to the technical content, my answer remains the only
possible correct answer. As for the style, I adopt that to the
milieu. In news groups, answers are short and to the point.


That's a different question, and in the past, I've explained how
compilers implement virtual functions. The original poster,
however, seems to already be aware of how virtual functions were
implemented.

At least you are not claiming that he "doesn't know what he's talking
about".
The question didn't concern the mechanics of the
issue.

IMHO, where the compiler puts the pointer(s) is indeed part of the way
it implements virtual functions.
Read the question again. He didn't ask about the mechanisms
used to implement virtual functions.

Did he not? See above.
I can quite understand a
programmer being curious about that, if he doesn't know it.

So your problem is not that someone may be interested in how virtual
functions are implemented, it's that you don't regard this question as
being related to how virtual functions are implemented.

Regards,
Peter
 
D

DaveB

Ian said:
Then why don't you ask on a group or forum where it would get an
appropriate answer? You mention gcc and VC, they both have their own
groups.

Well, I was hoping to get an answer from someone who has experience and
knowledge across a number of popular compilers. Getting JUST the answer
about gcc would have been "OK", but I didn't even get that. Where better
than a C++ group to ask? While I don't NEED the answer anymore, I am
still curious about it. When I first posted though, I did need the info,
and certainly not dogma.

The question remains unanswered, unless it's in one of the posts I
haven't read yet.
 
D

DaveB

Joshua said:
James said:
* red floyd:
On 4/2/2010 2:12 PM, DaveB wrote:
[insult to a member of the Committee redacted]

Well, there was a bit of insult, true.
On the other hand, I fail to see what James' state as a member
of the standardization committee has to do with anything.
I don't think it does (especially since I haven't been
particularly active lately). On the other hand, calling an
accurate and precise description of the issues "technical
gibberish" gives a very good idea of the competence (technical
and otherwise) of the poster. One gets the feeling that he
prefers to ignore real issues.

The question remains open. Maybe someone NOT in the priesthood of
technobabblery can answer it.

Maybe you could pull your head out of your ass and listen. Your
question does not make sense, even if you're adding on "for most
commercial compilers in common use". All commercial C++ compilers
support multiple inheritance and virtual inheritance. Some object in
such a hierarchy may will multiple vptrs. Your question was "Is the
vptr always at offset 0 of the object?" My answer is the question
"Which vptr?"

Finally, perhaps you could explain the problem you're trying to solve.
That would significantly help us give you useful answers.

I know it's been awhile since this thread was current, but your ATTITUDE
makes me want to respond. To you I say, go reread the OP and my follow up
posts. Stop creating context that does not exist to try and foster your
own agendas, may they be about saving the face of the demigod or
whatever.

The question remains unanswered.
 
D

DaveB

Peter said:
Am 02.04.2010 23:12, schrieb DaveB:

I agree.

James wasn't able to come down from his noble steed and answer a
simple question. It is my obervation from reading this ng for quite
some time that this newsgroup is inhabitated by people who tend to
indoctrinate the casual poster without themselves having any clue
about the question's or the questioner's background. I use the word
"indoctrinate" in order to avoid using the word "smartass". It is all
too tempting when you are an "expert" to react with arrogance and
presumtuousness to a "non-expert" question.

I agree, and I have made the experience myself, that many questions
arise from problems that people would not have if they hadn't made a
bad decision at some earlier point, i.e. they are trying to tackle the
problem from the wrong side. You can see from the question that they
are on the wrong track, and the best way to help them is to point out
some root cause, which quite often has yet to be wormed out of them.
I agree that sometines the devil is in the detail, and I'm a
perfectionist myself who gets lost in the details all too often.

But it is just wrong alienate people by answering "who cares?", or
"you shouldn't be asking this question". Maybe there's a reason that
you don't see at first. Maybe it is just pure curiosity, which, if
nothing else, makes it a perfectly legitimate question (for an
example, see Paul N's post).

Even though James' answer does have a technical correctness to it, it
is actually avoiding the question by moving to a different level. The
question was "In practice, ...", and this can very well be answered
with an "In practice, ..." answer. It was very evident that the
questioner knows this is an implementation detail, and portable code
should not depend on it. Maybe even platform dependent code should
not rely on it, and there may be better ways. But, again, you don't
know the intentions, so drawing premature conclusions is
inappropriate. Maybe answering the question and *then* adding "...
but what exactly is it that you want to do?" would come across in a
completely different light.
Maybe this question is compiler specific and should be asked in a
compiler specific newsgroup. Maybe the "across most compilers" part
has made it ok to be posted here. I'm sure this would not have been
the first time implementation details were discussed here.

Maybe James is a committee member. Maybe this should not have anything
to do with the way he answered the question, or the way the answer may
be taken.

Maybe Dave's reaction to James' answer was a bit harsh. Maybe he does
have a point.

So much for my two cents.

That is a perfectly correct observation. All of the above. Quite a breath
of fresh air compared to the tenseness, for lack of the better word, of
posting in a technical ng. I stayed away from this ng for a week, even
seeing responses to my posts, for feeling that a lynch mob was lurking.
Who wants THAT in their life? You are going places if you've not been
their already and back again, that's for sure. Maybe you should write a
book. Maybe you should not, and instead milk it for all it's worth. They
won't appreciate it and can't if it is just handed to them.
 
D

DaveB

Joshua said:
It is evident that he does not know what he's talking about, as he
does not know there can be multiple vptrs per object.

There IS something in that statement of yours that is allusive. You know
what it is for sure. I cannot, for I am looking from the outside in.
Something along the lines of you trying to kid everyone else that
something is true when it obviously is not true. Like everyone was a
child in your world. Don't they call that autism? So, we have, you are
autistic, or evil. Which is it? This isn't one of those "there is a
continuum" things. Are you autistic or evil? Hmm?
As he does not know what he's talking about, James gave the standard
line: "You probably don't need to do this, nor want to do this, nor
can do this portably. What are you trying to do? Perhaps there's a
sane way to do it without relying upon an implementation detail."

Are you autistic or evil? OK, you could be stupid, so there is at least
one other possibility. No offense if you are actually good.
If he was simply asking about the implementation detail to learn about
the C++ language (which is a good thing), then that's a different
story. In which case, the answer is: "It doesn't matter. It could be
always at the start (for a single vptr per object), or whereever the
compiler feels like putting it. It does not affect the algorithm in
any meaningful way, though it will affect binary compatibility if the
compiler were to change where it put it, or if a base class, direct or
indirect, was added or removed, etc. etc. for anything that can break
C ++ binary compatibility. As a practical matter, the compiler
probably puts the vptr at offset 0 for the simple cases, and has a
more complex solution for multiple and virtual inheritance."

Now it's a "numbers game", hardly a game though at all. When Jim Jones
tells you to drink the cool-aid, are you going to do it?
 
D

DaveB

Joshua Maurice wrote:

[He needs help. He seems to look up to you JK, go figure. Maybe look in
on him?]

I'm glad that when I was your age it was girls I was crying about and not
a great future facility with a programming language!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top