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]
Other format: [Raw text]

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


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