Re: system's gcc bug?

From: Poul-Henning Kamp (phk_at_phk.freebsd.dk)
Date: 03/31/04

  • Next message: David Rhodus: "Re: HEADS UP: Any umapfs users!"
    To: Rene Ladan <r.c.ladan@student.tue.nl>
    Date: Wed, 31 Mar 2004 12:20:35 +0200
    
    

    In message <20040331101834.GA21652@dyn-099164.nbw.tue.nl>, Rene Ladan writes:
    >
    >--rwEMma7ioTxnRzrJ
    >Content-Type: text/plain; charset=us-ascii
    >Content-Disposition: inline
    >
    >Hi,
    >
    >I'm getting runtime errors when executing the following program and
    >declaring one of the arrays:
    >
    >----------------
    >
    >#include <stdio.h>
    >
    >int main(void) {
    >/* int a[4] = { 0, 1, 2, 3 }; enable this line to get a buserror */
    > int *i;
    >/* int b[4] = { 0, 1, 2, 3 }; enable this line to get a segfault */
    > for (*i = 0; *i < 4; (*i)++)
    > printf("%p %i\n", i, *i);
    > return(0);
    > }

    You have allocated no storage backing for *i, so your for loop writes
    the integers 0...3 to a random place in memory.

    -- 
    Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
    phk@FreeBSD.ORG         | TCP/IP since RFC 956
    FreeBSD committer       | BSD since 4.3-tahoe    
    Never attribute to malice what can adequately be explained by incompetence.
    _______________________________________________
    freebsd-current@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-current
    To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
    

  • Next message: David Rhodus: "Re: HEADS UP: Any umapfs users!"

    Relevant Pages

    • Re: Seg Fault before execute main()
      ... And I do have some global variables (like as structs, int, and a FILE* ... pointer). ... Are you declaring large arrays? ...
      (comp.unix.programmer)
    • Re: Seg Fault before execute main()
      ... And I do have some global variables (like as structs, int, and a FILE* ... pointer). ... Are you declaring large arrays? ...
      (comp.unix.programmer)
    • Sockets Redirection problem
      ... I am trying to build a simple server that can execute local commands ... executing ls, cd, find and all of the normal unix utility programs. ... int execute; ...
      (comp.os.linux.development.apps)
    • Re: why cant functions return arrays
      ... int f; ... for such a language restricton. ... have been able to pass and return fixed-size arrays by value by ... Since there were no prototypes in K&R, there was no way to inform the ...
      (comp.lang.c)
    • Re: Implementing an 8 bit fixed point register
      ... It seems like implementing ALU operations on such arrays would ... If one only wants int arithmetic and all-bits logic, ... def bitset ... your approach could be easily modified to support slices: ...
      (comp.lang.python)