Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 94398 invoked from network); 29 Oct 2007 23:41:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Oct 2007 23:41:12 -0000 Received: (qmail 78656 invoked by uid 500); 29 Oct 2007 23:40:59 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 78642 invoked by uid 500); 29 Oct 2007 23:40:59 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 78631 invoked by uid 99); 29 Oct 2007 23:40:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2007 16:40:59 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2007 23:41:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5EC5B1A9832; Mon, 29 Oct 2007 16:40:51 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r589912 - /incubator/stdcxx/branches/4.2.x/etc/config/src/NO_INT_TRAPS.cpp Date: Mon, 29 Oct 2007 23:40:51 -0000 To: stdcxx-commits@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071029234051.5EC5B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebor Date: Mon Oct 29 16:40:50 2007 New Revision: 589912 URL: http://svn.apache.org/viewvc?rev=589912&view=rev Log: 2007-10-29 Martin Sebor STDCXX-624 * NO_INT_TRAPS.cpp (main): Worked even harder to foil optimizers and trigger a trap (such as SIGFPE) for integer arithmetic. Modified: incubator/stdcxx/branches/4.2.x/etc/config/src/NO_INT_TRAPS.cpp Modified: incubator/stdcxx/branches/4.2.x/etc/config/src/NO_INT_TRAPS.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/etc/config/src/NO_INT_TRAPS.cpp?rev=589912&r1=589911&r2=589912&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.x/etc/config/src/NO_INT_TRAPS.cpp (original) +++ incubator/stdcxx/branches/4.2.x/etc/config/src/NO_INT_TRAPS.cpp Mon Oct 29 16:40:50 2007 @@ -34,30 +34,49 @@ #endif // _WIN{32,64} -int get_int (); +int get_int (int); + + +volatile int int_zero; +volatile int int_one; + int main (int argc, char*[]) { - int int_zero = get_int (); - int int_one = get_int (); + // test expects to be called with no command line arguments + // i.e., (argc < 2) is expected to hold + + // argc used to try to foil optimizers + int_zero = get_int (argc); + int_one = get_int (argc); - int result; + int result [2]; TRY { - result = int_one / int_zero; + // use both division and modulo to try to foil optimizers + result [0] = int_one / int_zero; + result [1] = int_one % int_zero; } EXCEPT (1) { return 1; } // NEGATIVE test: successful exit status indicates a failure - return argc < 2 ? 0 : result; + return argc < 2 ? result [0] : result [1]; } -// foil optimizers -volatile int int_value = 0; +// use volatile to try to foil optimizers +volatile int int_value; -int get_int () +// use recursion to try to foil optimizers +int get_int (int arg) { - return int_value++; + if (1 < arg) + return get_int (arg - 1) + get_int (arg - 2); + + const int value = int_value; + + ++int_value; + + return value; }