Re: system's gcc bug?
From: Poul-Henning Kamp (phk_at_phk.freebsd.dk)
Date: 03/31/04
- Previous message: Rene Ladan: "system's gcc bug?"
- In reply to: Rene Ladan: "system's gcc bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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"
- Previous message: Rene Ladan: "system's gcc bug?"
- In reply to: Rene Ladan: "system's gcc bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|