Menu

#1923 Postincrement working incorrect!

closed-fixed
7
2012-02-06
2012-01-31
No

I use for my PIC18f258 the SDCC Compiler.
I use Snapshot Versions from http://sdcc.sourceforge.net/snap.php
sdcc-snapshot-i586-mingw32msvc-20120131-7268.zip 8524 K Jan 31 09:31
Postincrement working incorrect!
....
unsigned char VarBuffer[10], *BytePointer;

BytePointer = VarBuffer;

*BytePointer++ = 1; //BytePointer to be not incrementiert!

Discussion

  • David Cary

    David Cary - 2012-01-31

    The line "*BytePointer++ = 1;" should act the same as "*(BytePointer++) = 1;".
    The post-increment (++) has a higher precedence than the indirection (*), so after running that line VarBuffer[0] *should* be set to 1, and BytePointer *should* be incremented to point to VarBuffer[1].
    Is that what you are seeing, or are you seeing something more like "(*BytePointer)++" ?
    http://en.wikibooks.org/wiki/C_Programming/Reference_Tables#Table_of_Operators

     
  • Raphael Neider

    Raphael Neider - 2012-02-02

    code to reproduce the problem

     
  • Raphael Neider

    Raphael Neider - 2012-02-02

    This affects all ports: Using the attached file with a (global) BytePointer, even

    sdcc b3482217.c --i-code-in-asm --nogcse --nooverlay --nolabelopt --noinvariant --noinduction --nojtbound --noloopreverse --no-peep --dumpall -c

    looses the pointer increment (in both functions) somewhere during i-code optimization: in .dumppack, .dumprange and .dumprassgn the increment i-code is gone, all other .dump* (still) include it.

     
  • Raphael Neider

    Raphael Neider - 2012-02-02
    • labels: 608414 --> Live range problems
     
  • Philipp Klaus Krause

    Increasing priority, since bad code is generated silently.

    Philipp

     
  • Philipp Klaus Krause

    • priority: 5 --> 7
     
  • Philipp Klaus Krause

    Fixed in revision #7276.

    Philipp

     
  • Philipp Klaus Krause

    • assigned_to: nobody --> spth
    • status: open --> closed-fixed
     

Log in to post a comment.