Menu

#1457 Array of pointers in struct code generation error

closed-fixed
5
2013-05-25
2008-05-12
No

This bug might be the same as #1812570.

A small sample is attached.

On gcc f() return 1.
On sdcc

Discussion

  • Philipp Klaus Krause

    Code sample

     
  • Philipp Klaus Krause

    ASM generated

     
  • Philipp Klaus Krause

    Logged In: YES
    user_id=564030
    Originator: YES

    Sorry, I accidently hit the submit button.

    On sdcc there's an additional indirection. Instead of returning the expected value sdcc treats the expected value and whatever byte might be next as a pointer and the value it points to.

    Here's the generated asm (using sdcc -mz80 --fverbose-asm test.c):

    ; genPointerGet
    ld hl,#_x
    ld c,(hl)
    inc hl
    ld b,(hl)
    ; genPointerGet
    ld l,c
    ld h,b #_y NOW IN HL
    ld c,(hl) 1 NOW IN C
    inc hl
    ld b,(hl)
    ; genPointerGet
    ld a,(bc)

    _f_end::
    _y:
    .db #0x01
    _x:
    .dw _y
    .area _CODE
    .area _CABS

    While I use the Z80 port this probably affects all ports.

    Philipp

    File Added: test.asm

     
  • Maarten Brock

    Maarten Brock - 2008-09-08

    I can confirm this bug is present for mcs51 too.

     
  • Maarten Brock

    Maarten Brock - 2010-08-02
    • labels: --> Icode generator
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed
     
  • Maarten Brock

    Maarten Brock - 2010-08-02

    Fixed in SDCC 2.9.7 #5903.

     

Log in to post a comment.