Re: low-level question



On 30 Aug 2005 06:46:57 -0700, in comp.lang.c , "jesso"
<jesso1607@xxxxxxxxxx> wrote:

> Why does the following program output a 0?

Because of how that particular compiler or OS or hardware implements
undefined behaviour, vis writing off the end of an array.

>Explain in detail.

This isn't a C question, its a hardware / OS / compiler question.

>How could you prevent this outcome without changing the code?

Run on different hw/sw which handles the UB differently.
Compile with special "don't allow UB" options.
Don't run the app at all - it has a serious bug.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
.



Relevant Pages

  • Re: Inside an FBI Computer Forensics Lab
    ... properly reproduce or validate a piece of hardware. ... open source tools and well established procedures and methods are used ... like me could trivially design a black box which satisfied every ... possible to create a compiler that will recognizes your code during ...
    (alt.privacy)
  • Re: interesting use of NEXT SENTENCE vs. CONTINUE
    ... ANSI X3.23-1985 has USAGE BINARY. ... If J can be made an independent item which the compiler can put wherever it ... has to be associated with a hardware device in SPECIAL-NAMES. ... the same object code file to share the same instantiations of its code ...
    (comp.lang.cobol)
  • Re: UART RS232 "hello world" really taking shape now.
    ... executed at ELABORATION time - the COMPILER takes ... the hardware just sees a lookup table. ... you could stick with the nice simple "goto address" ... MSG "At B" ...
    (comp.arch.fpga)
  • Re: C to Java Byte Code
    ... The actual topic is about creating a Java equivalent for a C program. ... as well have argued that a byte, int, long, float, double can all be ... The values of the compiler depend on the underlying hardware. ...
    (comp.programming)
  • Re: interesting use of NEXT SENTENCE vs. CONTINUE
    ... Program name in quotes (allowed in '02 Standard) ... > If J can be made an independent item which the compiler can put wherever it ... > has to be associated with a hardware device in SPECIAL-NAMES. ... > that ALTER *always* modifies the address parameter of the hardware branch ...
    (comp.lang.cobol)