[fpc-pascal] Pointer question

2023-08-08 Thread Hairy Pixels via fpc-pascal
I just noticed this by accident and I don't understand. Why does " x := @r; " compile? I would expect it to fail like the next line where I cast to the explicit type. type TMyRec = record end; PMyRec = ^TMyRec; var x: PByte; r: TMyRec; begin x := @r;// works x := PMyR

Re: [fpc-pascal] Pointer question

2023-08-08 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal schrieb am Mi., 9. Aug. 2023, 04:59: > I just noticed this by accident and I don't understand. Why does " x := > @r; " compile? I would expect it to fail like the next line where I cast to > the explicit type. > > type > TMyRec = record end; > PMyRec = ^TMyRec; > v