Menu

Invalid AssignmentIntegerToAddress warning

NRK
2022-04-24
2022-04-25
  • NRK

    NRK - 2022-04-24

    Hi,

    Here's a minimal snippet to reproduce the issue.

    #include <string.h>
    
    extern char * fun(void);
    
    extern void
    test(void)
    {
        char *volatile s1, *volatile s2;
        s1 = fun();
        if ((s2 = strchr(s1, '/')))
            *s2 = '\0';
    }
    

    Run cppcheck with the following argument: cppcheck --enable=portability test.c

    Tested on version 2.6.3.

    Removing the volatile from s1 seems to make the warning go away.

     
  • CHR

    CHR - 2022-04-25

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11004

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.