Menu

selfAssignment false positive with use of designated initializer

2025-10-01
2025-10-01
  • Boris Blokland

    Boris Blokland - 2025-10-01

    typedef struct {
    uint8_t var1;
    uint8_t var2;
    uint8_t var3;
    uint8_t var4;
    } Foo;

    constexpr uint8_t var2 = 2;
    constexpr uint8_t var3 = 3;

    Foo foo {
    .var2 = var2, // <- false positive
    .var3 = var3
    };

     
  • CHR

    CHR - 2025-10-01

    Which version do you use? I'm unable to reproduce this with current head.

     
  • Boris Blokland

    Boris Blokland - 2025-10-01

    Cppcheck 2.13.0

     
  • CHR

    CHR - 2025-10-01

    Well, 2.18 is current, so you might consider updating.

     

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.