Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-09

Bus error in ARM architecture

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

There was a presentation about ARM in my university and I asked them about the errors when accessing unaligned memory.

The good news is that they said that the latest generation of ARM processors supports unaligned memory access.

They also asked me to send them some code which illustrates the problem, which they claim should not exist because the compiler should make sure everything is aligned.

So, does anyone have a particularly illustrative example?

thanks,

Felipe Monteiro de Carvalho

Reply by email

Florian Klaempfl
to Felipe Monteiro de Carvalho
They also asked me to send them some code which illustrates the problem, which they claim should not exist because the compiler should make sure everything is aligned.

FPC does too as long as you don't force the compiler to use a certain memory layout like using the packed keyword or casting unaligned pointers like plongint(100003)^:=1234;

Reply by email

Florian Klaempfl
to Florian Klaempfl
Show quoted text 7 lines
> > They also asked me to send them some code which illustrates the > problem, which they claim should not exist because the compiler should > make sure everything is aligned. FPC does too as long as you don't force the compiler to use a certain memory layout like using the packed keyword

Actually, FPC handles even packed types correctly by assuming that they are unaligned so the example below is the worst case but there the compiler can't do anything but the user can apply the unaligned keyword to tell the compiler that the data is unaligned:

Unaligned(plongint(100003)^):=1234;
or casting unaligned pointers like plongint(100003)^:=1234;

Reply by email

Florian Klaempfl
to Bernd Mueller: what do you think about http://bugs.freepascal.org/view.php?id=12137 ? IMO the unaligned…
Show quoted text 13 lines
Florian Klaempfl wrote: >> >> They also asked me to send them some code which illustrates the >> problem, which they claim should not exist because the compiler should >> make sure everything is aligned. > > FPC does too as long as you don't force the compiler to use a certain > memory layout like using the packed keyword or casting unaligned > pointers like plongint(100003)^:=1234; what do you think about http://bugs.freepascal.org/view.php?id=12137 ? IMO the unaligned directive should not be required in this case to "fix" the bug.

Indeed, but did anybody investigate why this goes wrong?

Reply by email

Bernd Mueller
to Florian Klaempfl: FPC does too as long as you don't force the compiler to use a certain memory layout like…
Florian Klaempfl wrote 8 lines
> > They also asked me to send them some code which illustrates the > problem, which they claim should not exist because the compiler should > make sure everything is aligned. FPC does too as long as you don't force the compiler to use a certain memory layout like using the packed keyword or casting unaligned pointers like plongint(100003)^:=1234;

what do you think about http://bugs.freepascal.org/view.php?id=12137 ? IMO the unaligned directive should not be required in this case to "fix" the bug.

Regards, Bernd.

Reply by email