From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47410 invoked by alias); 8 Jun 2015 09:54:48 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 47369 invoked by uid 48); 8 Jun 2015 09:54:44 -0000 From: "jan at epgmod dot phys.tue.nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/66458] New: Loading libgfortran.so changes the FPU exception flags Date: Mon, 08 Jun 2015 09:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jan at epgmod dot phys.tue.nl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg00655.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66458 Bug ID: 66458 Summary: Loading libgfortran.so changes the FPU exception flags Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: jan at epgmod dot phys.tue.nl Target Milestone: --- It appears that the mere act of loading libgfortran.so changes the FPU exception mask. It looks as if the library contains initialization code that I would have expected to appear in the program's start-up code. (Indeed it appears to do so in line 266 of libgfortran/runtime/main.c.) The problem can be reproduced by compiling the following C program: // fpuflags #include #include int main(int argc, char* argv[]) { volatile double d=0; feenableexcept(FE_ALL_EXCEPT); if (argc==2) { dlopen(argv[1],RTLD_NOW); } // I expect the expression 1/d to generate an FPU exception: return 1/d; } > gcc fpuflags.c -ldl -lm > ./a.out Floating point exception > ./a.out /usr/lib64/libstdc++.so.6 Floating point exception > ./a.out /usr/lib64/gcc/x86_64-suse-linux/4.8/libgfortran.so > #nothing happens After merely loading libgfortan.so, no FPU exceptions are generated anymore. Loading libstdc++.so does not result in such problem. This is a problem in my numerical application where libgfortran.so is loaded as a depency of a plugin library that is loaded at runtime. At first sight, this problem may be similar to that in PR20788.