#962 PIC16: assignments to bitfields by pointers

closed-fixed
5
2013-05-25
2005-08-02
Peter Onion
No

union PACKET
{
unsigned char raw[18];
struct
{
unsigned Len:4;
unsigned Dst:4;
unsigned Pro:4;
unsigned Src:4;

unsigned char bytes[16];
};
};

union PACKET p1,*p2;

p2 = &p1;

p2->Len = 5;
p2->Dst = 6;
p2->Pro = 7;
p2->Src = 8;

The assignments to the bitfields in the union do not work.
The first byte is set to 6 and the second to 8.
I think the problem is in
static void genGenPointerSet() in src/pic16/gen.c

It seems not to take any account of the possibility of
the result being a bitfield and always assigns the
whole byte.
Assignments like
p1.Len = 5;
work fine !

I'de try and fix it, but pcode is a mystery at the moment.

sdcc -v
SDCC : pic16/pic14 2.5.2 #1073 (Aug 1 2005) (UNIX)

Peter

Discussion

  • Peter Onion

    Peter Onion - 2005-08-02

    Code with assignments to bitfields with pointers.

     
  • Raphael Neider

    Raphael Neider - 2005-08-02
    • milestone: --> fixed
    • assigned_to: nobody --> tecodev
    • status: open --> closed-fixed
     
  • Raphael Neider

    Raphael Neider - 2005-08-02

    Logged In: YES
    user_id=1115835

    Fixed in SDCC 2.5.2 #1075.

    (The problem actually was in genGenPointerSet: the right hand side was tested for being a bitfield where the result should have been checked.)

     
  • Peter Onion

    Peter Onion - 2005-08-02
    • status: closed-fixed --> open-fixed
     
  • Peter Onion

    Peter Onion - 2005-08-02

    Logged In: YES
    user_id=1316390

    Can I open this again ?

    The fix has caused these messages to be displayed when
    assigning to a bitfield via a pointer...

    warning 179: possible code generation error at gen.c line 11558
    This is in case GPOINTER: code in static void genPackBits()

    However the code does seem to work ok.

    Peter

     
  • Peter Onion

    Peter Onion - 2005-08-03

    Logged In: YES
    user_id=1316390

    I've just built from fresh CVS and these messages have gone.
    It could have been my "hacking" late last night that broke
    someting.
    I'll close this again
    Sorry for the confusion.
    Peter

     
  • Peter Onion

    Peter Onion - 2005-08-03
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks