Issue Details (XML | Word | Printable)

Key: PCC-406
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

spurious warning for 'shift larger than type' of unaligned packed bitfield

Created: 01/Sep/12 10:23 AM   Updated: 02/Sep/12 10:39 AM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386


 Description  « Hide
I see a spurious warning when shifting an packed bitfield which is not aligned on a word boundary, as demonstrated by the following code fragment

struct foo {
    unsigned a:8;
    unsigned b:8;
    unsigned c:8;
    unsigned d:8;
    unsigned e:8;
    unsigned f:8;
};

struct foo a;
struct foo b __attribute__ ((__packed__));

void foo(void)
{
    unsigned long t;

    t = a.a << 24;
    t = a.b << 24;
    t = a.c << 24;
    t = a.d << 24;
    t = a.e << 24;
    t = a.f << 24;

    t = b.a << 24;
    t = b.b << 24; // xx
    t = b.c << 24; // xx
    t = b.d << 24; // xx
    t = b.e << 24;
    t = b.f << 24; // xx
}

which produces a warning for the marked lines
test.c, line 25: warning: shift larger than type
test.c, line 26: warning: shift larger than type
test.c, line 27: warning: shift larger than type
test.c, line 29: warning: shift larger than type

(the code handling RS looks familiar, not sure if affected also)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson made changes - 01/Sep/12 06:09 PM
Field Original Value New Value
Assignee Anders Magnusson [ ragge ]
Anders Magnusson made changes - 02/Sep/12 10:39 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]