Re: Code Comprehension
- From: "Phlip" <phlipcpp@xxxxxxxxx>
- Date: Sun, 27 Aug 2006 01:53:56 GMT
Pascal Bourguignon wrote:
The type of 0 and the type of '\0' are both int. There
is no difference between them in types of type or value.
The type of 0, '\0', "0", struct{char a[]="zero";} are both integer too.
Don't believe me?
This experiment doesn't test the front-end of the compiler, only the
back-end of the opcodes.
0xbff02deb: 0x00000100 ; another integer
You have discovered gdb's capacity to dump a memory location. This may have
very little to do with the C 'int' in the source code.
Specifically, if your experiment does not force the output opcodes to depend
on the size of the types involved, the compiler is free to optimize things
to machine words.
Saying "because my compiler" or "debugger does it like that" is not the same
as researching language law. All kinds of optimizations (and compiler bugs)
will get in the way.
Now write assert(sizeof(int) == sizeof '0'), or similar, and see what you
get. That's a slightly more accurate way to test - but still not language
law.
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
.
- Follow-Ups:
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- References:
- Code Comprehension
- From: jj
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- From: Rob Thorpe
- Re: Code Comprehension
- From: Pascal Bourguignon
- Code Comprehension
- Prev by Date: Re: VB6.0 and Constructors
- Next by Date: Re: Hashtable question
- Previous by thread: Re: Code Comprehension
- Next by thread: Re: Code Comprehension
- Index(es):
Relevant Pages
|