Fwd: New GCC compiler for 8086 cpu's

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unfortunately C doesn't distinguish between pointers to objects in the
heap and pointers to objects on the stack. Consider this:

{
  int buffer[256];
  int* pointer = buffer; // pointer points to stack frame
  pointer = malloc(256*sizeof(int)); // now it points to heap
  return buffer[0]; // so the same instruction here needs to be able
to cope with either
}

Vanilla C has two address spaces --- code and data. You're not allowed
to (portably) turn one to the other, so they can live in different
segments. But the stack and the heap are defined to be in the same
address space, and pointers to them have to be interchangeable. So
they need to live in the same segment.

-- 
┌─── http://www.cowlark.com ───
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup
--
To unsubscribe from this list: send the line "unsubscribe linux-8086" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel]     [Linux ia64]     [DCCP]     [Linux for ARM]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux