#995 Bad data pointers for fixed address variables

closed-fixed
5
2013-05-25
2005-10-21
xander
No

Bad code can be generated for pointer assignments if
the target is at an assigned location. Appears to
happen if there is a type cast in the assignment and not
happen if there isn't a type cast.

Version:
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51
/ds400/hc08 2.5.3 #1
121 (Oct 13 2005) (MSVC)

Command line: sdcc -c -mpic16 -pp18f2455 badptr1.c

File:

#include <pic18fregs.h>

extern char at 0x3a var1;
char var2;

void
main()
{
char *ptr1 = &var1;
char *ptr2 = &var2;
char *ptr3 = (char *)&var1;
char *ptr4 = (char *)&var2;

*ptr1 = 0;
*ptr2 = 0;
*ptr3 = 0;
*ptr4 = 0;
}

Here's the bad code:

; .line 16; badptr1.c *ptr3 = 0;
MOVLW 0x3a
MOVWF r0x00
CLRF r0x01
CLRF r0x02
MOVLW 0x00
MOVWF POSTDEC1
MOVFF r0x00, FSR0L
MOVFF r0x01, PRODL
MOVF r0x02, W
CALL __gptrput1

The upper byte of ptr3 should be set to 0x80, not 0.

Xander

Discussion

  • Raphael Neider

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

    Raphael Neider - 2005-11-11

    Logged In: YES
    user_id=1115835

    Fixed before SDCC 2.5.4 #1152, the emitted warning will
    disappear once I am convinced this makes sence...

     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks