#871 (void)volatile_reg produces no code

closed-fixed
5
2013-05-25
2005-01-24
Anonymous
No

The following C source produces no code to actually
read foo. The same happens with SFRs, some of which
have side effects when read (eg RCREG).

volatile char foo;

void f() {
(void)foo;
}

"char x = foo" also doesn't work, but "volatile char x
= foo" does seem to.

$ sdcc -v
SDCC : pic16 2.4.7 #933 (Jan 19 2005) (UNIX)

BTW, thanks to the developers for their quick
resolution of problems so far!

Chris Emerson
sdcc@mail.nosreme.org

Discussion

  • Raphael Neider

    Raphael Neider - 2005-01-24
    • milestone: --> 100454
     
  • Raphael Neider

    Raphael Neider - 2005-01-24

    Logged In: YES
    user_id=1115835

    This is a known bug (item #663539) of SDCC, it's not PIC16
    specific and might thus not be resolved in the near future.

    The first work around does not work as x is optimized away
    being unused, for now I advice the use of your second
    workaround (volatile something = <register>).

     
  • Raphael Neider

    Raphael Neider - 2005-01-24

    Logged In: YES
    user_id=1115835

    Sorry: this was a SDCC bug, now it's only a PIC16 bug.
    Actually this is rather easy to fix (in src/pic16/gen.c):

    static void
    genDummyRead (iCode * ic)
    {
    int i;
    FENTRY;

    pic16_aopOp (IC_RIGHT(ic),ic,FALSE);
    //fprintf (stderr, "%s: called on operand of size %d\n",
    __FUNCTION__, AOP_SIZE(IC_RIGHT(ic)));
    for (i=0; i < AOP_SIZE(IC_RIGHT(ic)); i++) {
    pic16_mov2w (AOP(IC_RIGHT(ic)), i);
    } // for i

    pic16_freeAsmop (IC_RIGHT(ic), NULL, ic, FALSE);
    }

    might do the trick.

    I would like to have Vangelis' opinion on this one before
    committing it.
    Would this not close #663539 (possibly in conjunction with
    my previous patch on iTemps in pic16_aopOp() & pic16_popGet())?

     
  • Vangelis Rokas

    Vangelis Rokas - 2005-01-25

    Logged In: YES
    user_id=770505

    I think this could do the job.
    Go ahead Raphael, commit this...

     
  • Raphael Neider

    Raphael Neider - 2005-01-26
    • milestone: 100454 --> fixed
    • assigned_to: nobody --> tecodev
    • status: open --> closed-fixed
     
  • Raphael Neider

    Raphael Neider - 2005-01-26

    Logged In: YES
    user_id=1115835

    Fixed in #943.

     

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

Sign up for the SourceForge newsletter:





No, thanks