3 ms·
It is much simpler in Pascal When you write to a pointer, it writes into memory. And it does not optimize it away. As if all pointers are volatile.
by benibela 5y ago
It is much simpler in Pascal
When you write to a pointer, it writes into memory. And it does not optimize it away. As if all pointers are volatile.
- cryptonector 5y agoBut then you have to constantly work around that in your code, making it read more like assembly in a way.
- pjmlp 5y agoWhich Pascal?
- benibela 5y agoFreePascal: procedure x; var a: integer; b: pinteger; begin b := @a; b^ := 1; b^ := 2; end; becomes project1.lpr:15 begin 0000000000401090 50 push %rax project1.lpr:17 b^ := 1; 0000000000401091 c7042401000000 movl $0x1,(%rsp) project1.lpr:18 b^ := 2; 0000000000401098 c7042402000000 movl $0x2,(%rsp) project1.lpr:19 end; 000000000040109F 59 pop %rcx 00000000004010A0 c3 ret Perhaps Delphi, too Although I do not know how much is by design and how much comes from bugs in the optimizer. But they said that one reason why they maintain their own optimizer rather than switching to LLVM. LLVM would "break" this function
- tored 5y agoPureBasic's new C-backend had the same problem, declaring them volatile solved it. https://www.purebasic.fr/english/viewtopic.php?t=78859 https://www.purebasic.fr/english/viewtopic.php?t=78859