#979 code pointer array referencing

closed-fixed
5
2013-05-25
2005-09-04
No

The attached code compiles without error or warning.
The resulting code incorrectly references code pointer
array 's' as if it were a generic pointer array in
function 'void proba(char* str[], ...);'. It seems the
compiler does not completely validate the storage class
specification during formal and actual parameter
matching.
Expected behaviour: error message indicating
incompatible storage class or incompatible types.

Command used to run SDCC:
>sdcc proba.c

SDCC version:
>sdcc --version
SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/
ds400/hc08 2.5.2 #1103 (Sep 2 2005) (MINGW32)

Discussion

  • Laszlo BORTEL

    Laszlo BORTEL - 2005-09-04

    mismatched storage class - code pointer array referencing

     
  • Laszlo BORTEL

    Laszlo BORTEL - 2005-09-04
     
  • Virgilio Eng. Villatora

    Logged In: YES
    user_id=1610032

    I found a similar problem.
    When you make a rom string table,
    code char* code string_list[]=
    {
    "pippo",
    "pluto",
    "paperino",
    ...
    };

    the compiler allocates the "string_list" elements'
    addresses in a 4-byte boundary fashion.

    When, down in your code, you use:

    - string_list[i]...
    or
    - pointer = string_list[0];
    pointer++;

    the increment (or address computation) is made on the
    generic pointer lenght that is 3 !!!

    NOTE: I workarounded the problem by Declariang a char*
    pointer and incrementing by 4... :(

     
  • Maarten Brock

    Maarten Brock - 2008-02-14
    • labels: --> C-Front End
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed
     
  • Maarten Brock

    Maarten Brock - 2008-02-14

    Logged In: YES
    user_id=888171
    Originator: NO

    Fixed in SDCC 2.7.5 #5009 by throwing an error.

     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks