kf: > > > Happens here too. However, > > > short word = *(short*)(s+1); > > > works as expected. > > Confirmed, that one works correctly.
Dave Dodge: > Well, the term "correctly" is a bit suspect. You can't convert an > arbitrary char* to a short* and dereference it without risking > undefined behavior, because among other things there's no guarantee > that the pointed-to location will be aligned properly as a short. "Correctly" is probably not the right term; "as expected on an x86" is probably a good one, though. That construct is clearly NOT portable, because (as you noted) many systems REQUIRE alignment. On the other, it's reasonable to expect the code to work on an x86, because alignment is REQUIRED to be merely an optimization (not a strict requirement) on an x86. It'd be wiser to rewrite that code (e.g., as a memcpy to a short which you KNOW it's aligned), since no matter what it's non-portable. --- David A. Wheeler _______________________________________________ Tinycc-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/tinycc-devel
