size of pointers

R

Richard Bos

av said:
av said:
Output:
[DS:0400]

Are you arguing that DS:0400 is an integer?

no but pointers are numbers,

Wrong. It is true that, if you take away all the parts of a pointer that are
not a number, then what remains (if anything) is a number. But that does
not mean pointers are numbers.

for the above example it should be a 16 bits x86 cpu

You don't know that.
"DS" should be a 16bits register.

You don't know that.
pointer i speak should be the 20 bits integer

You don't know that.
i don't "describe" i write "the definition"

You write bugger-all.
You can say it, but that doesn't make it true. If you want people to treat
your claim seriously, feel free to explain what part of the Standard, if
any, demonstrates that [DS:0400] is not a legal output for printf("[%p]\n",
p).

could be legal don't know

Exactly. You don't. In fact, you haven't the faintest clue about what
you're meddling with.

Richard
 
A

av

av said:
Output:
[DS:0400]

Are you arguing that DS:0400 is an integer?
yes
Wrong. It is true that, if you take away all the parts of a pointer that are
not a number, then what remains (if anything) is a number. But that does
not mean pointers are numbers.

for the above example
it should be a 16 bits x86 cpu
"DS" should be a 16bits register. pointer i speak should be the 20
bits integer (int20bits)((ds<<4)|0400)
(int20bits)((ds<<4)+0400)

printf has to write it in the output
You might describe them thus if you like, but that doesn't make them numbers
either.

you "describe"

i don't "describe" i write "the definition"

you and other appear confuse about the definition of pointers
it seems all you not have one... :))))))
Computer hardware designers are not limited by your imagination.

one integer of appriopriate dimension can find every momery location

why you all want more dimension for find the momory location?
Do you like to do hard what it is easy?
i can say above printf is bugged because not print:
[12:3456]

no,
because not print the 20bits number "(int20bits)((ds<<4)+0400)"
You can say it, but that doesn't make it true. If you want people to treat
your claim seriously, feel free to explain what part of the Standard, if
any, demonstrates that [DS:0400] is not a legal output for printf("[%p]\n",
p).

could be legal don't know
No, thank you - I am already happily married.

excuse me, is it better
"Merry Christmas"
?

Merry Christmas
 
M

mark_bluemel

subramanian said:
I have been thinking that all pointers(to any obejct) have the same
size. The size of a pointer is the size of an int. This is beause a
memory location is addressed by an int. Is that right/wrong?

Thank you for launching such an interesting thread.

I find it most instructive to see how many people seem to understand
little or nothing about logical reasoning and discussion:-

Poster 1: Here's what I think
Poster 2: Here's a counter-example or three
Poster 1: I still think it, so it must be true
Poster 3: Here's where the standard says that you are wrong
Poster 1: I still think it, so it must be true
Poster 4: Didn't you read what 2 and 3 said?
Poster 1: I still think it - here, let me redefine my terms to see if
that makes it true
 
A

av

av said:
av said:
On Tue, 19 Dec 2006 10:46:29 +0000, Richard Heathfield wrote:
You can say it, but that doesn't make it true. If you want people to treat
your claim seriously, feel free to explain what part of the Standard, if
any, demonstrates that [DS:0400] is not a legal output for printf("[%p]\n",
p).

could be legal don't know

Exactly. You don't. In fact, you haven't the faintest clue about what
you're meddling with.

so what is the clue in "standard C" about pointers?
What is it a pointer for the C language?
What is an address for the C language?

What is it a pointer for the C language?
[for me a pointer it is a memory location(or a register in the cpu)
that contain an address (memory or register that have enought bit to
hold every cpu possible memory positions)]

What is an address for the C language?
[for me it is a signed integer coordinate that find (if deferenced)
what there is in the memory location of its coordinate]
 
M

Mark McIntyre

no but pointers are numbers,

The question is, do you agree that DS:0400 is an address, and also not
an integer, and therefore a counterexample to your assertion.
they are coordinates that find a memory location
Indeed....

because i don't imagine why i have the need of more than 1 coordinate

.....but you have a very limited imagination.
for identify a memory location, yes pointers are integers

no.
Memory is a filing system. You may need several coordinates to find
the right bit - "basement level, room 4, filing cabinet B, drawer 2,
filed under 'octopus'". "Bank 0, chip 4, pin 6"


--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

so what is the clue in "standard C" about pointers?

Read 6.2.5 p20 and you will discover.
What is it a pointer for the C language?

see above
What is an address for the C language?

the location of an object.
What is it a pointer for the C language?
[for me a pointer it is a memory location(or a register in the cpu)
that contain an address (memory or register that have enought bit to
hold every cpu possible memory positions)]

You do realise that this definition doesn't require it to be an
integer? For instance, a memory location containing "Bank0, pins 4-55"
would meet this criterion.
What is an address for the C language?
[for me it is a signed integer coordinate that find (if deferenced)
what there is in the memory location of its coordinate]

Then your understanding of an address is wrong.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

(someone, possibly Richard H, wrote)
(int20bits)((ds<<4)+0400)

Ah, so you mean you can *convert* your address into an integer by
mathematically manipulating it.

So what? I can convert 3.1514926 into an integer too, or "hello mum"
for that matter. This doesn't make them integers.
i can say above printf is bugged because not print:
[12:3456]

because not print the 20bits number "(int20bits)((ds<<4)+0400)"

Virtually any compiler of the sort I grew up with would print
addresses in segment:eek:ffset format, eg DEAD:BEEF or whatever.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

Thank you for launching such an interesting thread.

I find it most instructive to see how many people seem to understand
little or nothing about logical reasoning and discussion:-

Poster 1: Here's what I think
Poster 2: Here's a counter-example or three
Poster 1: I still think it, so it must be true
Poster 3: Here's where the standard says that you are wrong
Poster 1: I still think it, so it must be true
Poster 4: Didn't you read what 2 and 3 said?
Poster 1: I still think it - here, let me redefine my terms to see if
that makes it true

Good summary. This goes into my sig file.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
S

Sourcerer

iamgodk said:
machine word is 32bit
char array[30]= "abc"
char *p=array;

sizeof(array) == 30
sizeof(p) == 4
<snip>

I have a compiler which would say sizeof(p) == 30 in this case.

--
"It is easy in the world to live after the world's oppinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/
 
R

Richard Heathfield

Sourcerer said:
iamgodk said:
machine word is 32bit
char array[30]= "abc"
char *p=array;

sizeof(array) == 30
sizeof(p) == 4
<snip>

I have a compiler which would say sizeof(p) == 30 in this case.

sizeof(p) is required to give the size of a pointer-to-char. There is
nothing in the rules forbidding this value from being 30, but it would be
rather unusual. Does it also give 30 for this code:

char anotherarray[31] = "def";
char *q = anotherarray;

size_t n = sizeof(q); /* does n reflect the size of the pointer, or of the
array? If the pointer, that's fine. If the array, your compiler is broken.
*/
 
R

Richard Heathfield

Richard Bos said:
How do you plan to reduce it to a McQuary-compatible 4x80?

Not ideal, but:

A: Here's what I think. B: Here are three counter-examples. A: I still think
it, so it must be true. C: Here's where the Standard says you are wrong. A:
I still think it, so it must be true. D: Didn't you read what B and C said?
A: I still think it - let me redefine my terms to see if that helps.
 
M

Munna

subramanian said:
I have been thinking that all pointers(to any obejct) have the same
size. The size of a pointer is the size of an int. This is beause a
memory location is addressed by an int. Is that right/wrong?

Yes. It is right. As memory address is always addressed interms of
integers the
size of pointer irrespective of its datatype is always same as that of
integers.
 
C

Clark S. Cox III

Munna said:
Yes. It is right. As memory address is always addressed interms of
integers the
size of pointer irrespective of its datatype is always same as that of
integers.

You couldn't be more wrong. I'm on a platform at this moment where

sizeof(int) == 4
sizeof(void*) == 8

Explain that, if, as you say, the size of pointer is always the same as
that of integers.
 
K

Keith Thompson

Munna said:
No.

It is right.

No, it is wrong.
As memory address is always addressed interms of
integers the size of pointer irrespective of its datatype is always
same as that of integers.

Wrong, wrong, wrong.

Read the standard. Read the FAQ. Read any decent C textbook. Read
the rest of this thread.

Pointers are not integers. Integers are not pointers. (Pointers
*may* be represented as integers on some systems.)
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top