[M3devel] "target specific pragmas"?

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Fri Feb 15 16:31:42 CET 2008


On Fri, Feb 15, 2008 at 03:18:11PM +0000, Jay wrote:
> I don't know but I could easily see pointer arithmetic banned on pointers to garbage collected types.
> I do NOT assume existing code will get garbage collection without source change.
> But then again, what does the Boehm collector do?

I don't know.  I'm mostly pointing out that it will involve radical 
change in C++ usage.

> I realize pointer arithmetic isn't even ever?often?usually?sometimes profitable these days i.e.:
>  
> unsigned array[n];
> for (size_t i = 0 ; i != n ; ++i)
> {   printf("%u\n", array[i]);
> }
>  
> vs.
> unsigned array[n];
> for (unsigned* p = array ; p != (array + n) ; ++p)
> {
>   printf("%u\n", *p);
> }
>  
> compilers can often do better with the first. I've heard this. I don't 
> know why.

Perhaps because it's easier to tell that array[i] is (supposed to 
be) within the array?  I believe C spec requires this (except for some 
futzing with the address just one element past the array, like array+n) 
but it's never checked in any C compiler I know of.  I once explored the 
possibility of performing all of these chacks in a C/C++ implementation, 
and concluded that it would require sufficiently different data 
representation from the programmers' expectations that it would be 
essentially useless.  One of the main uses of C is to communicate with 
strange program libraries that use strange in-memory data structures.

When they include garbage-collection into C++, I fear the result will be 
that in the absence of type-safety and array-bound safety, garbage 
collection will seem to be one more thing that causes programs to crash.

-- hendrik



More information about the M3devel mailing list