From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32418 invoked by alias); 23 Sep 2006 22:58:34 -0000 Received: (qmail 32390 invoked by uid 48); 23 Sep 2006 22:58:27 -0000 Date: Sat, 23 Sep 2006 22:58:00 -0000 Message-ID: <20060923225827.32389.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/29186] optimzation breaks floating point exception flag reading In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "kreckel at ginac dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-09/txt/msg02263.txt.bz2 List-Id: ------- Comment #9 from kreckel at ginac dot de 2006-09-23 22:58 ------- (In reply to comment #8) I am still not entirely sure whether we are really talking about the same problem. The original problem was that the compiler optimized assuming that the floating point division cannot have side effects, such that the offending division happens after the call to fetestexcept(3): #include #include int main() { double x = (double)printf("") + 1.0; // one double y = (double)printf(""); // zero feclearexcept(FE_ALL_EXCEPT); double z = x / y; // should set FE_DIVBYZERO if (fetestexcept(FE_ALL_EXCEPT)) { printf("flag set after call.\n"); } printf("%f/%f==%f\n",x,y,z); } Neither -ftrapping-math, nor -frounding-math change anything, as long as -O1 is turned on: The printf inside the if statement is *not* executed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29186