Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51417 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5791 invoked from network); 1 Feb 2011 13:35:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2011 13:35:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.177 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.177 mail-qy0-f177.google.com Received: from [209.85.216.177] ([209.85.216.177:55855] helo=mail-qy0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1F/98-42122-43C084D4 for ; Tue, 01 Feb 2011 08:35:49 -0500 Received: by qyk27 with SMTP id 27so6697230qyk.8 for ; Tue, 01 Feb 2011 05:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:from:date:message-id :subject:to:content-type; bh=LZ/fIpMJj5IkrGCID53aYFQlfORpnaVNN6DXaF40Z2I=; b=UB3pn7QqzkS1fDXHpFcV9qfKvFWv9TgwR8SRz2VNRywiiDFmlq8I1emQN0BCP5jsFf MTqoJhWLv9mqnXNTCH1wncd5G5GH6i+hWemhPodrgUjiEZmh4ImLVPegYBu+GSryS2Uv L9iYX03XWcwufW2r92vyE7PuFjwvwMYtPhOgg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:from:date:message-id:subject:to:content-type; b=o+NXXqGeJOwTRKKY9sVh96q43dRnAlQHKR0DmU8F4Gw2pv9SltDNrYamm16DtYFidU Ce+R+NtkN61dn8ilbUDOaZsCHC6ABthq0jbv2kq+nP47hup1SrxL1ib7/nEqoseECEDy j1knENUhe9Hm2aB80pVaQM7JRVkA2IQgEqotc= Received: by 10.229.190.204 with SMTP id dj12mr5324022qcb.101.1296567346262; Tue, 01 Feb 2011 05:35:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.130 with HTTP; Tue, 1 Feb 2011 05:35:26 -0800 (PST) Reply-To: RQuadling@googlemail.com Date: Tue, 1 Feb 2011 13:35:26 +0000 Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: size_t, casting and expression is always true (or false) From: rquadling@gmail.com (Richard Quadling) Hi. I was looking at the cause for a test failing. It came down to ... size_t n; if (n < 0) { // Code never reached as n is unsigned and cannot be negative. } I'm not a strong c developer, but from reading it seems that size_t is always unsigned. Using the windows compiler (and turning on all the warnings via /Wall though /W4 should be enough), this warning reports as ... xxx\yyy.c(nnn) : warning C4296: '>=' : expression is always false I then ran a full build and extracted all the C4926 warnings. main\network.c(1175) : warning C4296: '>=' : expression is always true main\streams\filter.c(363) : warning C4296: '<' : expression is always false main\streams\streams.c(921) : warning C4296: '>=' : expression is always true ext\mysqlnd\mysqlnd.c(1006) : warning C4296: '>=' : expression is always true ext\mysqlnd\mysqlnd.c(1031) : warning C4296: '>=' : expression is always true ext\mysqlnd\mysqlnd_loaddata.c(215) : warning C4296: '<' : expression is always false ext\mysqlnd\mysqlnd_loaddata.c(223) : warning C4296: '<' : expression is always false ext\mysqlnd\mysqlnd_ps.c(1480) : warning C4296: '<' : expression is always false ext\mysqlnd\mysqlnd_ps.c(1620) : warning C4296: '<' : expression is always false ext\standard\ftp_fopen_wrapper.c(645) : warning C4296: '>=' : expression is always true ext\standard\image.c(645) : warning C4296: '<' : expression is always false ext\standard\streamsfuncs.c(637) : warning C4296: '>=' : expression is always true ext\standard\streamsfuncs.c(677) : warning C4296: '>=' : expression is always true ext\standard\var.c(403) : warning C4296: '<' : expression is always false ext\pdo\pdo_stmt.c(463) : warning C4296: '<' : expression is always false ext\soap\php_encoding.c(2794) : warning C4296: '<' : expression is always false In the case of the bug [1], the incorrect type comparison resulted in the suppression of an error which cased the test to fail, leading me here. I think other comparisons in the above list are also suppressing errors (I think mysqlnd will fail to report a loss of connection during mysqlnd_handle_local_infile() for example). Regards, Richard. [1] http://bugs.php.net/bug.php?id=49072 -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY