This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [m32c] type precedence rules and pointer signs
- From: rridge at csclub dot uwaterloo dot ca (Ross Ridge)
- To: gcc at gcc dot gnu dot org
- Date: Wed, 30 Jan 2008 21:49:03 -0500 (EST)
- Subject: Re: [m32c] type precedence rules and pointer signs
DJ Delorie writes:
>extern int U();
>void *ra;
...
> foo((ra + U()) - 1)
...
>1. What are the language rules controlling this expression, and do they
>have any say about signed vs unsigned wrt the int->pointer promotion?
There is no integer to pointer promotion. You're adding an integer to a
pointer and then subtracting an integer from the resulting pointer value.
If U() returns zero then the pointer passed to foo() should point to
the element before the one that ra points to. Well, it should if ra
actually had a type that Standard C permitted using pointer arithmetic on.
Ross Ridge