Question about Solution to Exam Prep Sheet 9 a)

Hi,
I’m checking the solution currently an I am a bit confused about the type check in i.).
If I look into the C0p Static Semantics Reference it states that in the [PtrArith] Rule, the left Expresion can only have a type of k* and when I look at the types, that tells me, that k is a Scalar Type and void ist not a Scalar Type, so I don’t understand, how this is well-typed.
Can someone explain, what I’m not understanding here?

Thanks in advance!

You’re absolutely right that this is not well typed!

Pointer arithmetic only works when we know the size of the object that is pointed to.
However, void does not have a size, so we cannot do pointer arithmetic.

1 Like

Ok, so the solutions is wrong I guess?

Yes (or rather, the task is, as it does not make sense to generate code for an ill-typed expression).

1 Like

Ok, thanks!
I did try to generate coday anyway, by guessing the right instruction, but yeah.