[LLVMbugs] [Bug 9322] clang doesn't DCE dead switch cases (breaks Linux kernel at -O0)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 1 04:24:04 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9322

PaX Team <pageexec at freemail.hu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |pageexec at freemail.hu
         Resolution|FIXED                       |

--- Comment #9 from PaX Team <pageexec at freemail.hu> 2011-03-01 06:24:03 CST ---
i'm reopening this bug because i believe the problem i see is related to the
same underlying cause. in linux/kernel/signal.c:has_pending_signals there's the
following construct (linux/include/linux/signal.h has similar):

 102 »·······switch (_NSIG_WORDS) {
 103 »·······default:
 104 »·······»·······for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;)
 105 »·······»·······»·······ready |= signal->sig[i] &~ blocked->sig[i];
 106 »·······»·······break;
 107
 108 »·······case 4: ready  = signal->sig[3] &~ blocked->sig[3];
 109 »·······»·······ready |= signal->sig[2] &~ blocked->sig[2];
 110 »·······»·······ready |= signal->sig[1] &~ blocked->sig[1];
 111 »·······»·······ready |= signal->sig[0] &~ blocked->sig[0];
 112 »·······»·······break;
 113
 114 »·······case 2: ready  = signal->sig[1] &~ blocked->sig[1];
 115 »·······»·······ready |= signal->sig[0] &~ blocked->sig[0];
 116 »·······»·······break;
 117
 118 »·······case 1: ready  = signal->sig[0] &~ blocked->sig[0];
 119 »·······}

on i386 _NSIG_WORDS is #defined to 2 with ->sig[] having 2 elements as well.
clang r126742 generates the following warning on this:

kernel/signal.c:108:19: warning: array index of '3' indexes past the end of an
array (that contains 2 elements) [-Warray-bounds]
        case 4: ready  = signal->sig[3] &~ blocked->sig[3];

and ditto for line 109.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list