Date: Wed, 09 Oct 2002 08:30:20 -0700 From: ChildsC@bcrail.com To: josepht@cstone.net, freebsd-stable@FreeBSD.ORG Subject: RE: gcc2.95.4 pointer not defined Message-ID: <02Oct9.082221pdt.119096@gatekeeper.bcrail.com>
next in thread | raw e-mail | index | archive | help
The error is valid because you need to allocate some space for the
integer that your pointer points to such as:
/* pointer.c - pointer test */
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int *ip;
ip = malloc( sizeof(int) );
*ip = 50;
printf ("%d\n", *ip);
return (EXIT_SUCCESS);
}
-----Original Message-----
From: Joe Talbott [mailto:josepht@cstone.net]
Sent: Wednesday, October 09, 2002 8:18 AM
To: freebsd-stable@freebsd.org
Subject: gcc2.95.4 pointer not defined
With the following simple program on 4.6-STABLE from Mon Sep 9 11:27:32 EDT
2002 roughly (tried as well on 4.6-STABLE from Mon Jun 24 18:24:30 EDT 2002)
both gcc 2.95.4 20020320. Both give SIGSEGV on line 9 (*ip = 50). gdb
tells
me:
ip = (int *) 0x0
Here's the source:
/* pointer.c - pointer test */
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int *ip;
*ip = 50;
printf ("%d\n", *ip);
return (EXIT_SUCCESS);
}
I've tried this on a RedHat box and a SunOS box both worked as expected.
Joe
--
Memory is the second thing to go as you get older.
I forget what the first one was...
-- I forgot
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?02Oct9.082221pdt.119096>
