#1457 Array of pointers in struct code generation error


This bug might be the same as #1812570.

A small sample is attached.

On gcc f() return 1.
On sdcc


  • Philipp Klaus Krause

    Code sample

  • Philipp Klaus Krause

    ASM generated

  • Philipp Klaus Krause

    Logged In: YES
    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)

    .db #0x01
    .dw _y
    .area _CODE
    .area _CABS

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


    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.

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

Sign up for the SourceForge newsletter:

No, thanks