
Lubomir Bourdev wrote: [...]
I believe this is indeed the problem. GIL needs to read/write a type bigger than a byte that starts at a char* address, so it is possibly not aligned.
One approach is to special-case platforms which cannot dereference at a non-byte boundary (I couldn't find a config flag that detects this, anyone?) and provide a special solution for such platforms. The solution I imagine will involve static recursion that reads/writes each byte and shifts it in place.
[...] For Tru64/CXX there is an easy workaround available, please refer to the attached patch for this. Of course this isn't a general solution, although I would think that acc supports something similar, which then could be wrapped into a macro hiding the platform dependency. But you should be aware that unaligned accesses usually hurt performance a lot, even on platforms where the hardware is able to deal with it. HTH, Markus Index: channel.hpp =================================================================== --- channel.hpp (revision 41078) +++ channel.hpp (working copy) @@ -292,8 +292,8 @@ data_ptr_t operator &() const {return _data_ptr;} protected: static const integer_t max_val = (1<<NumBits) - 1; - const bitfield_t& const_data() const { return *static_cast<const bitfield_t*>(_data_ptr); } - bitfield_t& data() const { return *static_cast< bitfield_t*>(_data_ptr); } + __unaligned const bitfield_t& const_data() const { return *static_cast<const bitfield_t*>(_data_ptr); } + __unaligned bitfield_t& data() const { return *static_cast< bitfield_t*>(_data_ptr); } private: void set(integer_t value) const { // can this be done faster?? const integer_t num_values = max_val+1; @@ -383,7 +383,7 @@ integer_t get() const { return integer_t((this->const_data()&channel_mask) >> FirstBit); } void set_unsafe(integer_t value) const { this->data() = (this->const_data() & ~channel_mask) | (value<<FirstBit); } private: - void set_from_reference(const BitField& other_bits) const { this->data() = (this->const_data() & ~channel_mask) | (other_bits & channel_mask); } + void set_from_reference(__unaligned const BitField& other_bits) const { this->data() = (this->const_data() & ~channel_mask) | (other_bits & channel_mask); } }; } } // namespace boost::gil