Project

General

Profile

Actions

Defect #23

closed

default BitField assignment operator doesn't do what one might expect

Added by Tony Ciavarella about 4 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
09/24/2020
Due date:
% Done:

0%

Estimated time:

Description

Consider this:

union A
{
    disorder::utility::BitField<uint64_t, 0, 32> x;
    disorder::utility::BitField<uint64_t, 32, 32> y;
    uint64_t all;
};

A a1, a2;

a1.x = 1;
a1.y = 2;

a2.x = a1.x; // this actually assigns all 64 bits of a1 to a2, not just the x 32-bits.

Consider overriding the default operator= to make this behave more intuitively. Overriding operator= will make BitField usage more complex because it will cause the move assignment operator, copy constructor, and move constructor to become non-trivial which will also bubble up to whatever data structures BitFields are used in.

Note that the above example can be made to do what is expected by writing it like this instead:

a2.x = a1.x.get(); // this only assigns the x 32-bits of a1 to a2.

Actions #1

Updated by Tony Ciavarella about 4 years ago

  • Description updated (diff)
Actions #2

Updated by Tony Ciavarella about 4 years ago

  • Status changed from In Progress to New
Actions #3

Updated by Tony Ciavarella almost 2 years ago

  • Status changed from New to Resolved

this is fixed by r2098

Actions #4

Updated by Tony Ciavarella almost 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF