This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: type based aliasing again


> Well this option would just tell the compiler that there are no aliases,
> guaranteed, on my full responsibility. Like in a function:
>
>    double f(double *x, double *y, long n)
...
>
> when I the programmer happen to know there can't be an alias (the
> memory areas x and y are totally nonoverlapping on the full range)
> but the compiler can't detect that since n could have any value.

IBM's xlC and Apple's MrC use the following syntax for this case:

#pragma disjoint (x,y)

Where any pointer name with any number of dereferences, denoted by an
asterix, can appear in a group.

AFAIK, C9X's restrict keyword doesn't help here since we're only asserting
that these two pointers aren't overlapping, not that they don't overlap with
something else of interest to the compiler.

Another possible solution is a syntax I've seen in Microsoft's VC++:

__assume(x != y);

Where __assume() is usually a non-debug replacement for assert(). This
particular expression doesn't denote lack of overlap, but possibly some
suitable expression can be devised that works. This is also a desirable
general mechanism for other assertions. (If anybody knows of a paper on this
as a general mechanism, I'd love to read it.)

+------------------------------------------------------------+
| Alexander M. Rosenberg           <mailto:alexr@_spies.com> |
| Nobody cares what I say. Remove the underscore to mail me. |


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]