Intellisense error


Could someone explain this error:

value computed is not used - an indicates the line below

in this function

// ------------------------------------------------------------------------------
char *replace_char(char *str, char in, char out)
// ------------------------------------------------------------------------------
    char *tmp = str;

    while (*tmp)
        if (*tmp == in)
            *tmp++ = out; /* assign first, then incement */

    *tmp = '\0';
    return str;


I’d say this is an order of execution question and not really an error message but a warning pointing you to the following

  • What do you want to increment?
  • The address the pointer points to or the content of the value stored there?

BTW, what should those two asterisks after the semicolon?


thanks - Two asterisks are typo

Its meant to be a simple replace function for a c-string - loop through the spring, replace any instance if ‘in’ with ‘out’, null terminate and return

It does work - I am curious as to why it would raise a warn when it is used?


Because the providers of programming tools are aware that people sometimes “expect” the code to do something but in fact write it in a way to do something else. And for cases where there might be some ambiguity it’s safer to issue a warning than just assume the user does know what he’s doing :wink: