#78 wrong linenumber presented in warning

closed-accepted
None
5
2007-01-18
2007-01-18
No

the following code produces a warning with a false linenumber:

1 int main(void)
2 {
3 volatile char a=1;
4
5 if (a)
6 return 1;
7 else
8 if(a == 1000) // this condition will never be true
9 return 2; // so this line is unreachable code
10
11 return 0;
12 }

compiling it with SDCC: 2.6.4 #4567 (Jan 18 2007) (UNIX) produces the following warning:

test.c:8: warning 94: comparison is always false due to limited range of data type
test.c:6: warning 126: unreachable code

the linenumber 6 should be 9 ("return 2;" is not reachable.

the patches is attached (output of "svn di SDCClabel.c")

Discussion

  • Borut Ražem

    Borut Ražem - 2007-01-18
    • assigned_to: nobody --> borutr
    • status: open --> closed-accepted
     
  • Borut Ražem

    Borut Ražem - 2007-01-18

    Logged In: YES
    user_id=568035
    Originator: NO

    Günther,

    thank you for the patch. I applied it with a small correction: the werrorfl looks like:
    werrorfl (tic->filename, tic->lineno, W_CODE_UNREACH);
    instead of:
    werrorfl (loop->next->filename, tic->lineno, W_CODE_UNREACH);
    so that the right file name is displayed in the warning message.

    Fixed in svn revision #4578.

    Borut

     

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

Sign up for the SourceForge newsletter:





No, thanks