RESOLVED FIXED 224207
Suppress -Warray-bounds warning spam in Bitmap.h
https://bugs.webkit.org/show_bug.cgi?id=224207
Summary Suppress -Warray-bounds warning spam in Bitmap.h
Michael Catanzaro
Reported 2021-04-05 14:44:05 PDT
With GCC 11, there is a huge warning spam coming from Bitmap.h: In file included from ../../Tools/TestWebKitAPI/Tests/WTF/Bitmap.cpp:27: DerivedSources/ForwardingHeaders/wtf/Bitmap.h: In function ‘void TestWebKitAPI::testBitmapIsFull() [with WordType = unsigned int]’: DerivedSources/ForwardingHeaders/wtf/Bitmap.h:229:24: warning: array subscript ‘_Type {aka const unsigned int [4]}[0]’ is partly outside array bounds of ‘WTF::Bitmap<9, unsigned int> [1]’ [-Warray-bounds] 229 | bits[n / wordSize] &= ~(one << (n % wordSize)); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../Tools/TestWebKitAPI/Tests/WTF/Bitmap.cpp:104:33: note: while referencing ‘smallBitmap1’ 104 | Bitmap<smallSize, WordType> smallBitmap1; /* Will hold values specified in expectedSmallBits1. */ \ | ^~~~~~~~~~~~ ../../Tools/TestWebKitAPI/Tests/WTF/Bitmap.cpp:108:5: note: in expansion of macro ‘DECLARE_BITMAPS_FOR_TEST’ 108 | DECLARE_BITMAPS_FOR_TEST() \ | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../Tools/TestWebKitAPI/Tests/WTF/Bitmap.cpp:441:5: note: in expansion of macro ‘DECLARE_AND_INIT_BITMAPS_FOR_TEST’ 441 | DECLARE_AND_INIT_BITMAPS_FOR_TEST(); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It prints over 3000 lines of warnings for every translation unit that includes Bitmap.h. After squinting at this for a while, I failed to understand why GCC thought there was a problem here, so instead I added a runtime assert to see if the array bounds are ever exceeded. They are not, at least not by TestWTF nor when smoketesting Epiphany.
Attachments
Patch (1.37 KB, patch)
2021-04-05 14:46 PDT, Michael Catanzaro
no flags
Patch for landing (1.23 KB, patch)
2021-04-07 14:46 PDT, Michael Catanzaro
no flags
Michael Catanzaro
Comment 1 2021-04-05 14:45:59 PDT
(Note the debug assert might be controversial because this function seems to be called very frequently. I don't mind taking that out if requested.)
Michael Catanzaro
Comment 2 2021-04-05 14:46:40 PDT
Michael Catanzaro
Comment 3 2021-04-07 14:45:50 PDT
Let's land without the ASSERT. I don't think it matters very much either way.
Michael Catanzaro
Comment 4 2021-04-07 14:46:41 PDT
Created attachment 425442 [details] Patch for landing
EWS
Comment 5 2021-04-07 16:49:45 PDT
Committed r275646: <https://commits.webkit.org/r275646> All reviewed patches have been landed. Closing bug and clearing flags on attachment 425442 [details].
Note You need to log in before you can comment on or make changes to this bug.