I've answered on gcc-help instead.
On 12 February 2017 at 00:55, David Guillen Fandos wrote:
> Hello!
>
> I have the following function
> std::tuple getRawIdx(uint16_t tidx) {
> return std::make_tuple(localidx.entries[tidx].indx_ptr,
> localidx.entries[tidx].indx_size);
> }
>
> Where s is a struct like
>
> typedef struct __attribute__((packed)) {
> uint32_t indx_ptr;
> uint8_t indx_size;
> } _i_idx_entry ;
>
> The error I get is:
>
> cannot bind packed field
> ‘((DBIndex*)this)->DBIndex::localidx.DBIndex::_i_idx::entries[((int)tidx)].DBIndex::_i_idx_entry::indx_ptr’
> to ‘unsigned int&’
>
> If extend the tuple to include a 3rd field and I return some other thing
> it just works:
>
> return std::make_tuple(localidx.entries[tidx].indx_ptr,
>localidx.entries[tidx].indx_size,
>tidx, prefb);
>
> I think gcc is trying to do some smart optimization or something and
> packed does not work because of tuple alignments not being packed.
>
> Any ideas?
> Thanks!
> David
>