From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Larmour To: Shaun Jackman Cc: crossgcc list Subject: Re: unaligned pointers Date: Sun, 29 Oct 2000 19:19:00 -0000 Message-id: <39FCE8C7.98A1801F@redhat.com> References: <007d01c01e63$59b1e440$6801a8c0@gray.internal> X-SW-Source: 2000-10/msg00144.html Shaun Jackman wrote: > > Can GCC generate the code necessary to load from and store to unaligned > pointers? Ditto for unaligned members of structures. > In the case of structure members the compiler knows compile-time which are > aligned and which are unaligned, and genereate the respective code. Although > it doesn't at the moment. Nor does it warn me of the access to an unaligned > structure member (w/ -Wall). > For pointers though, how do I indicate a given pointer can possibly be > unaligned, and needs odd-alignment safe dereferncing? In general, if gcc deferences a pointer, then it will assume that what the pointer points to is aligned appropriately for the type it points to. If it doesn't, it's your problem :-). If you want to be able to access unaligned structures, you would have to copy it first (and use a char * pointer to access it for copying, since that is the only type guaranteed to be safe for this). Jifl -- Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS Tel: +44 (1223) 728762 "Plan to be spontaneous tomorrow." || These opinions are all my own fault ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com