Re: Code Comprehension



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!!!


.



Relevant Pages

  • Re: Code Comprehension
    ... This experiment doesn't test the front-end of the compiler, ... as researching language law. ... are not the semantics of an integer. ... advantage that it could work with unicode characters too). ...
    (comp.programming)
  • Re: export
    ... >> compilation tests. ... > The front-end widely acknowledged to be the most conformant is also the ... > front-end which offers the most options for supporting legacy code. ... > that it will not be the fastest compiler on a particular platform. ...
    (comp.lang.cpp)
  • Re: Fortran 2003 Test Suite
    ... And commercial compiler companies would be willing to pay. ... compilers use the EDG front-end. ... At PathScale, we got a lot of value out of the Unicomp test suite. ...
    (comp.lang.fortran)
  • Re: PCC, TCC - new front end
    ... I am thinking of starting with PCC or TCC or something like that and ... make your own compiler using gcc. ... If you want to work with a compiler collection that may be easier to ... learn to build a new front-end LLVM is meant to be much easier from what ...
    (comp.compilers)
  • Re: export
    ... The front-end widely acknowledged to be the most conformant is also the ... g++'s portability often means that it will not be the fastest compiler ... fastest compile times. ...
    (comp.lang.cpp)