Messages in this thread | | | From | David Laight <> | Subject | RE: [PATCH] phy: fix compiler array bounds warning on settings[] | Date | Thu, 6 Mar 2014 09:13:09 +0000 |
| |
From: Bjorn Helgaas > I'm stumped. phy_find_valid() is static and only called from one > place. The 'idx' argument is always the result of phy_find_setting(), > which should always return something between 0 and > ARRAY_SIZE(settings), so I don't see any way idx can be < 0. > > I stripped this down as far as I could; the resulting test code is at > http://pastebin.com/pp1zMEWu if anybody else wants to look at it. I'm > using gcc 4.8.x 20131105 (prerelease), with "-Warray-bounds -O2" > flags. > > I hesitate to suspect a compiler bug, but it is very strange. For > example, in my test code, replacing "MAX_NUM_SETTINGS" with "2" gets > rid of the warnings. MAX_NUM_SETTINGS is known to be 2 at > compile-time, so I don't know why this should make a difference.
I can't get an array bounds error from the gcc 4.8.1-10ubuntu9 at all. Not even when I index the array with a constant 3. I wonder if they compiled it out!
David
| |