sizeof 'a' returns 4

N

Nelu

Frederick said:
Kenny McCormack posted:

[blither blather]
I'm not sure I understand what you're getting as... but are you
suggesting that this newsgroup bears some sort of association with
Asperger Syndrome?


Kenny is a troll, whose intention is disrupt the newsgroup. Just ignore
him. If you use a killfile, he's a good candidate.

Man, you guys must really be worried.

Your responses are sooooo predictable.

Just a general observation: when the teacher repeats the rules he's
only predictable if the pupil learnt them but doesn't give a damn
about them. That makes a brat... a modern time \sout{rock'n'roll}
troll. Some people grow up, eventually.
 
B

Barry Schwarz

posted:



typedef T double;


unsigned SizeOf( T const t )
{
const char * const current = (const char*)&t;

const char * const next = (const char*)(&t + 1);

return next - current;
}

Your typedef has a syntax error.

What does the size of a double have to do with the original question?

Did you mean
typedef int T;

If the OP realized that 'a' was of type int (and not char), he
probably wouldn't have asked the question in the first place.


Remove del for email
 
D

Dik T. Winter

....
> Some chance.
>
> Just google up some examples of his "help".

Well, if somebody posts a follow-up with completely irrelevant information,
you can expect some comments. I will give full comments:
> typedef T double;
>

Interchange 'T' and 'double'
> unsigned SizeOf( T const t )
> {
> const char * const current = (const char*)&t;
> const char * const next = (const char*)(&t + 1);
> return next - current;
> }

This does not answer the original question (why sizeof 'a' == 4). I think
it was intended as a response to a question in another thread about a user
replacement of sizeof. And it also fails as that. It returns
sizeof (double). So can Frederick Gotham explain the intent of his
article?
 
O

Old Wolf

Richard said:
Frederick Gotham said:

Syntax error.

Interesting (?) fact I encountered while verifying your answer:

typedef double;

is NOT a syntax error; nor is:

double;
 
L

lovecreatesbeauty

Old said:
Interesting (?) fact I encountered while verifying your answer:

typedef double;

is NOT a syntax error; nor is:

double;

Does following answer the question?

lovecreatesbeauty

/*quoting begins*/
A.2.2 Declarations

(6.7) declaration-specifiers:
storage-class-specifier declaration-specifiers(opt)
type-specifier declaration-specifiers(opt)
<snip>

(6.7.1) storage-class-specifier:
typedef
<snip>

(6.7.2) type-specifier:
<snip>
double
<snip>
/*quoting ends*/
 
G

Guest

Old said:
Interesting (?) fact I encountered while verifying your answer:

typedef double;

is NOT a syntax error; nor is:

double;

Right, it's a constraint violation, and not a syntax error, because a
type-specifier followed by a semicolon can be a valid declaration:

struct S { /* ... */ };

Another interesting fact (? here too):

struct S { /* ... */ } typedef;

is allowed as well, and does not define any variable.
 
R

Richard Heathfield

Frederick Gotham said:
Richard Heathfield posted:



So as not to clutter the newsgroup, I would request in future that, if
you choose to scrutanise and correct my code, that you correct the error
rather than simply indicate that an error is present -- it will be of
benefit to us all.

Sorry, Frederick. I thought I had given sufficient information, given the
limited number of ways in which it could be wrong.
Another thing, and this is your own perogative of course, maybe you'd
like to be more "social" about how you offer your counsel?

Your original reply was not only an attempt to spoonfeed a homework answer
(always a bad idea) but was also an incorrect answer to the wrong question,
and it would not even compile.

This is your own prerogative, of course, but maybe you'd like to focus on
getting your own house in order before you start telling other people what
to write?
It's pretty
clear that my error was more a question of "getting things muddled up"
rather than having a deficit of proficiency.

My comment that your code had a syntax error was not a claim that you had a
"deficit of proficiency". It was a comment that your code had a syntax
error. These are not the same thing. But you can try for "deficit of
proficiency" if you like.
 
M

Mark McIntyre

Just google up some examples of his "help". Certainly seems to think
he's something special : but all I can see are self grandizing smart ass
comments generally designed to bemuse the newbie. Aspergers is a great
description IMO.

Congrats, you get the fsckwit of the week award.
--
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

On Sun, 18 Jun 2006 22:41:39 +0000 (UTC), in comp.lang.c ,
Frederick said:
Kenny McCormack posted:

[blither blather]
I'm not sure I understand what you're getting as... but are you
suggesting that this newsgroup bears some sort of association with
Asperger Syndrome?


Kenny is a troll, whose intention is disrupt the newsgroup. Just ignore
him. If you use a killfile, he's a good candidate.

Man, you guys must really be worried.

Your responses are sooooo predictable.

*replonk*
--
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
 

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
474,184
Messages
2,570,973
Members
47,529
Latest member
JaclynShum

Latest Threads

Top