delete[] p or delete[] *p

G

Goran

As far as I am aware you , like the others , beleive that with a simple 1d
array:
int* p= new int[6];
p is a pointer to a single int and  not a pointer to the array. But
according tot he standards, Bjarne and C FAQs, a pointer to a 1d array is
exactly the same type of pointer as a pointer to a single element.

This is your __interpretation__, and is __not__ an accurate one.

Goran.
 
P

Paul

As far as I am aware you , like the others , beleive that with a simple 1d
array:
int* p= new int[6];
p is a pointer to a single int and not a pointer to the array. But
according tot he standards, Bjarne and C FAQs, a pointer to a 1d array is
exactly the same type of pointer as a pointer to a single element.

This is your __interpretation__, and is __not__ an accurate one.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is your interpretation?

Is it the case that, as I said, you think p does not point to an array?

I say p can point to an array you say this is not accurate. What exactly,
IYO, is innacurate about this?
 
P

Paul

I accept, no problem. He is not saying that a char* __is__ a pointer
to an array of char, he is saying that it can __point to__.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Do you accept that the char* points to an array of chars or not?

I accept that we __commonly say__ that, when such pointer points to
the first element of an array, it points to the array. Underlying
truth is, though, that such pointer __is__ a pointer to a __single__
array element (here, first).

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Well you have to accept it don't you. Because this is the way it works.
But you add a "but" clause to your acceptance, so you still disagree.
You seem confused, inconsistent and you don't know what you are talking
about.

Your "but" clause seems to suggest that the pointer doesn't really point to
an array because the pointer-type is a pointer to int.
But you cannot make this clear because instead of saying the pointer-type
you say such pointer___is__a pointer to a___single___ array element. When
you probably mean to say the pointer-type is a pointer to an int.
 
G

gwowen

This is your __interpretation__, and is __not__ an accurate one.

Do you have this conception that, after being told this a large finite
number of times, a light Paul will come to believe it? Because I have
no freaking idea how you came by that conception.

I believe he's wrong.
You believe he's wrong.

Paul believes he's right.
Maybe some others agree with him - I don't know

There is no possible way on earth any of us are going to convince the
other. None at all.

Accept that. And let it go.

Let it go, man. Just let it go.

And when he starts a new thread in an attempt to restart his argument,
ignore it. Please. Just ignore it. However much it riles you - and
it clearly upsets you quite a lot - please, please, please, in the
name of rationality, just ignore it.

Please.

If you saw a man on the street wearing a sandwich board amd shouting
"Justin Bieber is the antichrist", and quoting scripture to back it
up, I don't believe you'd waste hours of your life debating him on the
street - and exhaustively searching the Bible for evidence that the
antichrist will not appear as a mildly annoying Canadian - not least
because you'd look as crazy as he is.

Well, that applies on the internet too.

You don't have to prove yourself right - just prove yourself sane.
 
P

Paul

Leigh Johnston said:
No, conclusion is fine. Nonsense are your attempts to equal "is"
and
"points to". And, they lead to poor coding and errors (see
your own
attempts earlier in this thread to explain your stance).
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Do you accept that the same pointer-type can point to an char
or an
array of
char's?

I accept that when pointer points to the first element of an
array, we
commonly say that it points to an array.

But in

int a[1];
int (*p)[1] = &a;

p is an actual, in C type system sense, pointer to an array. And
because of such things, one should take mental note when saying
"pointer to an array" for a pointer pointing to array's first
element.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Do you accpet that when Bjarne Stroustrup says a char* can point
to a
single char or an array of chars. He is in fact techincally
correct. And
he fully understand the C++ type system.
Do you not think its more likely that you are incorrect, if you
disagree
with him?


Stop appealing to authority. Bjarne is being informal but
obviously he
is correct as what he is saying does not disagree with what others
have been telling you; basically "type" in the following two
phrases
can refer to a *different* type:

1) "pointer to a type"
2) "the type of the object pointed to".

Your problem is your inability to differentiate the two phrases
above.
"pointer to" is different to "pointed to" or "points to" as
"pointer
to" partially describes the type of the pointer variable not
what is
being pointed to.

No its quite straight forward: Bjarne says that a char* pointer can
point to a single char or an array of chars, you say otherwise.

You obviously did not read my reply: "pointer to" is different to
"points to". Take the time to properly read the replies people
make or
**** off and stop posting to this newsgroup you time waster.

No pointer to and points to is more or less the same thing. Both
terms
refer to the pointed to object.

No they are not "more or less the same thing"; "more or less the same
thing" is woolly language and has no place in a technical discussion;
also see below.


You say that a char* does not point to an array and only points to
a
single char. You further your wrongness by saying that a type:
char (*)[3]
is a pointer to a 1d array, when this is actually a pointer to a 2d
array , because pointers to arrays are (n-1) dimensions of the
pointed
to array.

You are wrong again:

char a[3]; // 1d array
char(*p)[3] = &a; // pointer to a 1d array

No you are wrong because this doesn't mean that this type of pointer
cannot be used as a pointer to a 2d array like so:
char a[3][3];
char (*p)[3] =a;

No p is still a pointer to a 1d array; your code is invoking array
pointer decay as it is equivalent to:

char a[3][3];
char (*p)[3] =&a[0];

Your understanding of arrays and pointers is flawed.

Your understanding is flawed, the C++ standard defines a pointer to a
2d
array to be of this type/ level of indirection.

Your understanding is flawed:

char(*)[N] is a pointer to a 1d array
char(*)[N1][N2] is a pointer to a 2d array
No this is the pointer TYPE.
When a 1d array of chars is converted to a pointer the pointer-type is
char* , not char (*)[somesize].

Its all explained in the standards.
You take the address of a thus introducing an unneccessary extra
level
of indirection.

Of course; a pointer to an array is an extra level of indirection; a
pointer to an array element isn't.

No. According to the C++ standards, a pointer to an array is a
different
level of indirection, but in the opposite direction from what you are
saying.

That was just gibberish.






Now if Bjarne says one thing and you say it is incorrect, then
who is
more likely to be wrong?

Your appeal to authority is wrong on two counts:

1) An appeal to authority is a logical fallacy;
2) The authority you are appealing to actually does not agree with
your claim/argument (as I have described above).
The authority states that char* can point to a single char or an
array
of chars. Which is in direct agreement with me and disagrees with
you.

Again: there is a difference between "a pointer to" and "points to".
Consider:

struct base {};
struct derived : base {};

derived o;
base* p = &o;

p is a pointer to a base even though it points to an object of derived
type.

Its a pointer to what it points to , its the same thing.

No it isn't. A pointer has a type; a pointer's type does not have to
be the same type as the object it points to.

This is where you fail , because you have on many occassions said that a
pointer to T, can only point to a T.

No I haven't; I have said that a pointer to a scalar is not a pointer to
an array and have said that "pointer to" is different to "points to" if,
like you, we disregard technical accuracy.
You are the technically innacurate. If an object X points to an array then
it is a pointer to an array. Both terms involving the verb "point" where it
refers to the pointed-to object.

You are incorrectly trying to suggest that the term "is a pointer to" means
something different than the pointed to object.
If you mean its a pointer type pointer to X then say that because this is
the techincally accurate term. Not your twisted nonsense.

I have said that a pointer to a scalar is not a pointer to an array; a
pointer to a scalar can point to an array element of the same scalar type.


I am not inconsistent; you are both confused and cause confusion due to
your use of ambiguous terminology and lack of technical accuracy.
You are one who is inaccurate , the term "points to" and "is a pointer to"
both refer to the same pointed to object.
You attempt to use the term "is a pointer to" to mean is of type pointer to.

You are confused by the pointer-type and what it points to.

It is obvious to all that it is you who has been confused; is
currently confused and probably will continue to be confused as you
refuse to learn from others.





Additionally if the C++ standards defines something and you say its
incorrect, then who is more likely to be wrong?

Where have I have said that the C++ Standard is incorrect? I haven't
said any such thing so you are either lying or are confused.

You said that char (*p)[3] points to a 1d array and not to a 2d
array,
but the standard states different.


p is a pointer to a 1d array and the standard does not state
different; p may point to a 1d array subobject of a 2d array and if it
is pointing to the first 1d array subobject of the 2d array then one
can say it points to a 2d array but this is informal language and
technically inaccurate. As others have said "points into" is a more
acceptable term that covers all bases.

This is utter nonsesne the C++ standard states clearly what a pointer
to
an array is and how it behaves.
A pointer to a 2d array, when derefernced returns a 1d array subobject.
And that is a FACT defined in the C++ Standard.
It doesn't matter how much you try to worm your way around this fact,
it
is clearly defined in the standards and until you accept this fact you
will always be wrong.

You are the one spouting utter nonsense; the Standard says no such
thing. Dereferencing a pointer to a 2d array results in a reference to
a 2d array as the following code shows:

template <typename T, std::size_t N1, std::size_t N2>
void is_a_2d_array(T (&a)[N1][N2])
{
std::cout << "2D array; dimensions = " << N1 << " x " << N2;
}

int main()
{
char a[7][42]; // 2D array
char (*p)[7][42] =&a; // pointer to a 2D array
is_a_2d_array(*p); // dereferenced pointer to a 2D array is a 2D array
reference
}
According to the C++ standards when a 2d array is converted to a pointer
the pointer-type is a (n-1) dim array. Thus the correct conversion for a
2d array to a pointer is:
char a[7][7];
char (*pa)[7] = a;

pa above is *not* a pointer to a 2D array; it is a pointer to a 1D array.

No , it points to a 2d array.
Therefore it is a pointer to a 2d array. Its type is a pointer to a 1d array
because this is how pointers ot arrays work in C++.

You're POV that if something points to an array it is not a pointer to an
array is very confused and techincally inaccurate.
Indeed; this is implicit array-to-pointer conversion; nobody has said that
this is incorrect.
You are saying it doesn't point to a 2d array, so therefore you don't seem
to accept that this type of pointer is used to point to a 2d array.

Correct I have created an extra level of indirection to create a pointer
to a 2D array; without that extra level of indirection I would be creating
a pointer to a 1D array via implicit array-to-pointer conversion.
No you are talking about the pointer type but you use incorrect terminology.
When we say X is a pointer to an array this doesn't not mean the same as x
is a pointer-type pointer to an array.
The term "is a pointer to" refers to the pointed-to object and is not a term
that defines the pointer type for example:

void* p = (void*)new int[6];

p is a pointer to an array of 6 ints. p is not a pointer to void.
 
P

Paul

This is your __interpretation__, and is __not__ an accurate one.

Do you have this conception that, after being told this a large finite
number of times, a light Paul will come to believe it? Because I have
no freaking idea how you came by that conception.

I believe he's wrong.
You believe he's wrong.

Paul believes he's right.
Maybe some others agree with him - I don't know
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I believe Bjarne stroustrup and the C faq's and the C++ standard.
Yes I beleive Bjarne Stroustrup is correct when he says that a char* can
point to an single char OR an array of chars.

Just accept you are in the wrong and run away, with a few defiant name
calling insults as you run off.
 
G

Goran

 Your "but" clause seems to suggest that the pointer doesn't really point to
an array because the pointer-type is a pointer to int.

My "but" accepts the desire for expediency in communication, nothing
more. Pointer still __is__ a pointer to the first element of the
array.

Goran.
 
G

Goran

As far as I am aware you , like the others , beleive that with a simple1d
array:
int* p= new int[6];
p is a pointer to a single int and not a pointer to the array. But
according tot he standards, Bjarne and C FAQs, a pointer to a 1d array is
exactly the same type of pointer as a pointer to a single element.

This is your __interpretation__, and is __not__ an accurate one.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is your interpretation?

I don't need interpretation, I know what is technically and
practically correct. And your __interpretation__ isn't any of that.

Goran.
 
P

Paul

Leigh Johnston said:
On 15/04/2011 14:24, Paul wrote:
[garbage snipped]
No you are talking about the pointer type but you use incorrect
terminology. When we say X is a pointer to an array this doesn't not
mean the same as x is a pointer-type pointer to an array.
The term "is a pointer to" refers to the pointed-to object and is not a
term that defines the pointer type for example:

This must be a royal "we" as nobody else (nor the Standard) agrees with
you.

Well the standard uses the term "is a pointer to" to refer to the pointed to
object, for example the standard uses terms like:
is a pointer to an incomplete object.

It's obviously refering to the pointed to object, and not the pointer-type.
void* p = (void*)new int[6];

p is a pointer to an array of 6 ints. p is not a pointer to void.

No; p *is* a pointer to void.
Your terminology is incorrect, the pointer-type is void pointer but this
does not mean it points to a void.

p is a pointer to....*drumroll*.. what it points to. Your attempt to
suggest otherwise is nothing more than a desperate attempt to make your
arguemnt correct, but it only makes you even more incorrect.
 
P

Paul

As far as I am aware you , like the others , beleive that with a simple
1d
array:
int* p= new int[6];
p is a pointer to a single int and not a pointer to the array. But
according tot he standards, Bjarne and C FAQs, a pointer to a 1d array
is
exactly the same type of pointer as a pointer to a single element.

This is your __interpretation__, and is __not__ an accurate one.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is your interpretation?

I don't need interpretation, I know what is technically and
practically correct. And your __interpretation__ isn't any of that.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

My interpretation is backed up by quotations form Bjarne Stroustrup and the
C FAQs, and the C++ standard.
You don't even have an argument anymore because your original argument has
been proven incorrect.
 
G

Goran

I don't need interpretation, I know what is technically and
practically correct. And your __interpretation__ isn't any of that.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

My interpretation is backed up by quotations form Bjarne Stroustrup and the
C FAQs, and the C++ standard.

It's not. You are __attempting__ to back it up through faulty logic
and spurious insults.

Goran.
 
P

Paul

Leigh Johnston said:
Well the standard uses the term "is a pointer to" to refer to the
pointed to object, for example the standard uses terms like:
is a pointer to an incomplete object.

It's obviously refering to the pointed to object, and not the
pointer-type.

You can repeat your nonsense as many times as you like but it will remain
as incorrect nonsense. It is obviously not referring to the pointed to
object as you cannot have an object of an incomplete type; you can have an
"incomplete object type" though which is the term the Standard actually
uses not "incomplete object".
void* p = (void*)new int[6];

p is a pointer to an array of 6 ints. p is not a pointer to void.

No; p *is* a pointer to void.
Your terminology is incorrect, the pointer-type is void pointer but this
does not mean it points to a void.

My terminology is correct; p is a pointer to void.
No its not there is no such object as a void in C++. p does not point to a
void.

p is a pointer to void; what object p points to does not change the type
of p; "pointer to void" is the type of p.
As I have said you are talking about the pointer-type not what it points to.
A pointer-type void pointer, does not point to a void as you incorrectly
suggest.
 
P

Paul

I don't need interpretation, I know what is technically and
practically correct. And your __interpretation__ isn't any of that.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

My interpretation is backed up by quotations form Bjarne Stroustrup and
the
C FAQs, and the C++ standard.

It's not. You are __attempting__ to back it up through faulty logic
and spurious insults.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yes it is.
Who are you to say otherwise when you don't even have an argument anymore?

Remind me what exactly is your argument again?
Oh you cant because your argument has been proven to be incorrect.
 
P

Paul

Your "but" clause seems to suggest that the pointer doesn't really point
to
an array because the pointer-type is a pointer to int.

My "but" accepts the desire for expediency in communication, nothing
more. Pointer still __is__ a pointer to the first element of the
array.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You argument was that it was a pointer to the first element and only to the
first element. It did not point to any array.

Now since I have presented evidence that proves the experts think otherwise
you seem to have semi accepted the truth , but you do not fully accpet it.

So be it , that is your problem.
<shrug>
 
P

Paul

Leigh Johnston said:
Leigh Johnston said:
On 15/04/2011 14:49, Paul wrote:
What you have done is not a standard array-pointer conversion. You
have
created an extra level of indirection.

Correct I have created an extra level of indirection to create a
pointer to a 2D array; without that extra level of indirection I
would
be creating a pointer to a 1D array via implicit array-to-pointer
conversion.

No you are talking about the pointer type but you use incorrect
terminology. When we say X is a pointer to an array this doesn't not
mean the same as x is a pointer-type pointer to an array.
The term "is a pointer to" refers to the pointed-to object and is
not a
term that defines the pointer type for example:

This must be a royal "we" as nobody else (nor the Standard) agrees
with you.

Well the standard uses the term "is a pointer to" to refer to the
pointed to object, for example the standard uses terms like:
is a pointer to an incomplete object.

It's obviously refering to the pointed to object, and not the
pointer-type.

You can repeat your nonsense as many times as you like but it will
remain as incorrect nonsense. It is obviously not referring to the
pointed to object as you cannot have an object of an incomplete type;
you can have an "incomplete object type" though which is the term the
Standard actually uses not "incomplete object".



void* p = (void*)new int[6];

p is a pointer to an array of 6 ints. p is not a pointer to void.

No; p *is* a pointer to void.

Your terminology is incorrect, the pointer-type is void pointer but
this
does not mean it points to a void.

My terminology is correct; p is a pointer to void.
No its not there is no such object as a void in C++. p does not point to
a void.

I never said there was a void object however "pointer to void" is a
correct term; from the Standard:

3.9.2/4
"Objects of cv-qualified (3.9.3) or cv-unqualified type void* (pointer to
void), can be used to point to objects
of unknown type."
That is speaking about a pointer-type.
What part of pointer-type don't you understand?

The type of pointer is not always what it points to, especially with a void
pointer.
I never said anything "pointed to a void"; I said p was a "pointer to
void" which is a correct term (see above).
No its incorrect if you omit the word "type".
It's type is void pointer.

When a pointer is a pointer to X, X is the pointed to object, not the
pointer type.
When you say a pointer is type pointer to X, then there is a different
meaning implied altogether.

You INCORRECTLY use the former term , with the later definition.

I do not care about terms such as "pointer-type" that you define; I care
about terms defined by the C++ Standard.
You don't care about anything except YOU being right, even when you are
blatantly wrong.

You have once again been proven wrong and you are and always will be a
proven idiot. Why don't you go **** off back into yur hole or something and
stop speaking bullshit as usual :)

A void pointer points to a void HAHA , you are such a fuckin moron Leigh.
Sometimes you really need to take a good look in the mirror and maybe bang
your head of it a few times. Not to hard though or you might break it. (the
mirror not your head)
 
P

Paul

Leigh Johnston said:
On 15/04/2011 18:55, Paul wrote:
[...]
A void pointer points to a void HAHA , you are such a fuckin moron
Leigh. Sometimes you really need to take a good look in the mirror and
maybe bang your head of it a few times. Not to hard though or you might
break it. (the mirror not your head)

Who said a void pointer points to a void? I certainly didn't; I said
"pointer to void" which is a correct term (according to the C++ Standard)
and is a synonym of "void pointer".

You are just one big fail troll with nothing better to do; it is quite
pathetic really.
No its a ..... type pointer to void. More commonly a void pointer.

You said it was a pointer to a void. This is different from saying its a
type pointer to void.
 
P

Paul

Leigh Johnston said:
Now you are backed into a corner you can only respond to argument by
telling lies. I did not say it was a "pointer to a void"; I said it was a
"pointer to void" which is a synonym of "void pointer". Read the
Standard.
You said it was a pointer to void when you meant it was a TYPE pointer to
void.
You were incorrect, and I'm not in a corner.
 
P

Paul

Leigh Johnston said:
I said what I meant and I meant what I said.


Yeah, whatever, dream on.
Just admit it you are wrong.

int* p = new int[7];

The above is a pointer to an array of ints. Its type is int* because thats
the way pointers to arrays work in C++.
This is supported by many authorities and the C++ standard, why do you
refuse to acccept its the way things are?
Your latest attempt to disprove this has been an attempt to twist the
meaning of "is a pointer to" to mean "is type pointer to", where you posted
a snippet from the standards ref:

3.9.2/4
"Objects of cv-qualified (3.9.3) or cv-unqualified type void* (pointer
to void), can be used to point to objects
of unknown type."

The above snippet clearly states *TYPE* , it agrees with me not with you.
HAHA. You fail so much its becoming ridiculous.
 
G

Goran

My "but" accepts the desire for expediency in communication, nothing
more. Pointer still __is__ a pointer to the first element of the
array.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You argument was that it was a pointer to the first element and only to the
first element. It did not point to any array.

Now since I have presented evidence that proves the experts think otherwise

Eh!? No, you presented no evidence. You __misinterpreted__ an
interview and a part of the standard.

Goran.
 
P

Paul

My "but" accepts the desire for expediency in communication, nothing
more. Pointer still __is__ a pointer to the first element of the
array.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You argument was that it was a pointer to the first element and only to
the
first element. It did not point to any array.

Now since I have presented evidence that proves the experts think
otherwise

Eh!? No, you presented no evidence. You __misinterpreted__ an
interview and a part of the standard.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
No I quoted some text from websites, no interview misquotations.

And I did not misinterpret that standard, the standard clearly states that
pointer representation of arrays are (n-1) dimensional.
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top