project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.52k stars 2.02k forks source link

[BUG] Clang-Tidy error #35121

Open jlatusek opened 3 months ago

jlatusek commented 3 months ago

Reproduction steps

New version of clang-tidy avaliable with latest pigweed version, found new types of errors:

2024-08-19 08:28:29 INFO TIDY ../../src/app/EventManagement.cpp: /mnt/dane/projects/matter/connectedhomeip-second/out/sanitizers/../../src/app/EventManagement.cpp:107:51: error: pointer arithmetic on polymorphic object of type 'CircularEventBuffer' can result in undefined behavior if the dynamic type differs from the pointer type [bugprone-pointer-arithmetic-on-polymorphic-object,-warnings-as-errors]`  
    107 | next = (bufferIndex < aNumBuffers - 1) ? &apCircularEventBuffer[bufferIndex + 1] : nullptr;
            | ^~~~~~~~~~~~~~~~~~~~~
/mnt/dane/projects/matter/connectedhomeip-second/out/sanitizers/../../src/app/EventManagement.cpp:109:20: error: pointer arithmetic on polymorphic object of type 'CircularEventBuffer' can result in undefined behavior if the dynamic type differs from the pointer type [bugprone-pointer-arithmetic-on-polymorphic-object,-warnings-as-errors]
    109 | current = &apCircularEventBuffer[bufferIndex];

Bug prevalence

always

GitHub hash of the SDK that was being used

ff6863ed127fb1a8a6f134ed15b2ed98ed75e418

Platform

core

Platform Version(s)

No response

Anything else?

No response

bzbarsky-apple commented 3 months ago

@jlatusek Does marking CircularEventBuffer as final silence the warning?

jlatusek commented 3 months ago

@bzbarsky-apple you are right, it silence the warning

bzbarsky-apple commented 3 months ago

Great, a warning that makes sense and goes away when it's not relevant. :) @jlatusek do you want to create that PR, or should I?

jlatusek commented 3 months ago

I will fix that in PR in which I found it #34194

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Remove stale label or comment or this will be closed in 30 days.