#929 Incorrect \0 handling in string literals.

closed-fixed
nobody
5
2013-05-25
2005-05-24
Anonymous
No

I'm using the pic16 backend, but I think this is a
frontend bug:

const char foo[] = "@@\0@@";

results in a string containing only "@@".

Discussion

  • Erik Petrich

    Erik Petrich - 2005-05-26

    Logged In: YES
    user_id=635249

    It's a bug in the pic's customized glue.c; this example
    compiles correctly for all the ports except pic14 & pic16.

     
  • Erik Petrich

    Erik Petrich - 2005-05-26
    • labels: 101552 --> 608414
     
  • Raphael Neider

    Raphael Neider - 2005-05-26

    Logged In: YES
    user_id=1115835

    Fixed for PIC16 in SDCC 2.5.1 #1037; PIC14 seems to generate
    correct code already, doesn't it...

     
  • Erik Petrich

    Erik Petrich - 2005-05-26

    Logged In: YES
    user_id=635249

    It seems to be a slightly different problem on PIC14;
    compiling for the 16f84 it generates:

    _foo
    RETW 0x00
    RETW 0x00
    RETW 0x00

    If I remove the \0 from the string, it generates a warning:
    WARNING: couldn't associate label _foo with an instruction

    However, a non-string initializer seems to work fine:
    const char foo[] = {64,64,0,64,64};

    _foo
    RETW 0x40
    RETW 0x40
    RETW 0x00
    RETW 0x40
    RETW 0x40

     
  • Erik Petrich

    Erik Petrich - 2005-05-26
    • labels: 608414 --> pic14 target
     
  • Raphael Neider

    Raphael Neider - 2005-05-26
    • milestone: --> fixed
    • status: open --> open-fixed
     
  • Raphael Neider

    Raphael Neider - 2005-05-26

    Logged In: YES
    user_id=1115835

    Actually, I overlooked the const keyword -- PIC16 is fixed
    for _const_ char [] only now, PIC14 should be fixed as well
    (for some reason the actual string's emission was commented
    out). The PIC14 approach only works iff
    label1: retlw 0x01
    label2: retlw 0x02
    results in PC@label2 == PC@label1 + 1 (I don't know PIC14s,
    but this should hold...). Thanks for your hints, Erik!

     
  • Raphael Neider

    Raphael Neider - 2005-07-04
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.