tag:blogger.com,1999:blog-2514816548490606877.post1107894550422883937..comments2023-05-30T19:24:49.007+05:30Comments on Fedora-ARM: Fedora-ARM: alignment errorsKedar Sovanihttp://www.blogger.com/profile/06720656914623203587noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-2514816548490606877.post-11803502975703511812009-11-04T05:39:22.892+05:302009-11-04T05:39:22.892+05:30BTW, that code is also an aliasing violation in ad...BTW, that code is also an aliasing violation in addition to the alignment violation.<br /><br />Can't the ARM be configured to trap on alignment errors instead of silently doing the wrong thing? At least an Address Error (68k) or Bus Error (SPARC) is clear.Kevin Koflerhttp://www.tigen.org/kevin.kofler/noreply@blogger.comtag:blogger.com,1999:blog-2514816548490606877.post-15905801037500371992009-11-03T18:11:22.990+05:302009-11-03T18:11:22.990+05:30This is precisely why the ISO C language standard ...This is precisely why the ISO C language standard says:<br />"A pointer to an object or incomplete type may be converted to a pointer to a different object or incomplete type. <b>If the resulting pointer is not correctly aligned for the pointed-to type, the behavior is undefined.</b>"<br /><br />So doing (int*)p itself is bad on ARM. One should use memcpy() in such cases.<br /><br />And, I suggest dropping the implicit int return type for main(). ;-)Syamhttps://www.blogger.com/profile/05218298295445175825noreply@blogger.com