On Sun, 13 Feb 2000 03:45:55 -0800, "davidturetsky" <[EMAIL PROTECTED]> was 
crying out from somewhere
  about: Re: Segmentation fault

davidturetsky> It looks as though I was running into problems when trying to 
scan an input
davidturetsky> file using c notation which is less efficient of memory, so I'm 
in the
davidturetsky> process of revising all of the I/O to use c++ resources. Still, 
it comes as
davidturetsky> a surprise, but I'm very early on the gcc learning curve


Reading this I am wondering if you actually did allocate memory for the 
variables, or even did you do the right thing?

for example, getting input for a double with scanf will require you doing 
something like

double a;
scanf("%g", &a);

You can even do double a; scanf("%g", a); and it might still work on MS 
compiler, it won't on gcc.


That was my personal experience migrating my own code.
I found many invalid pointers in my code. 
MSC seems to be very "relaxed" in handling invalid pointers. 
Linux is very harsh and kills your app with a segfault as soon as you try to
access it.

For example, this code segfaults on Linux, which used to work perfectly fine on 
MSC:


char * bitsofmemory = malloc (BIG_SIZE); FILE*f =fopen(FILENAME, ATTRIBUTE);
if (!(bitsofmemory && f)) {
   free(bitsofmemory); fclose(f) /* try to clean up and it dies...*/
   return ERROR;
}



---------------------------------------------------------------------------
Junichi Uekawa, a.k.a. dancer
 a member of the Dept. of Knowledge Engineering and Computer Science, 
   Doshisha University.
... I pronounce "Linux" as [Day-bee-enne]

Reply via email to