public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/66458] New: Loading libgfortran.so changes the FPU exception flags
@ 2015-06-08  9:54 jan at epgmod dot phys.tue.nl
  2015-06-08 10:02 ` [Bug libfortran/66458] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jan at epgmod dot phys.tue.nl @ 2015-06-08  9:54 UTC (permalink / raw)
  To: gcc-bugs

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 <fenv.h>
#include <dlfcn.h>

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-08  7:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-08  9:54 [Bug libfortran/66458] New: Loading libgfortran.so changes the FPU exception flags jan at epgmod dot phys.tue.nl
2015-06-08 10:02 ` [Bug libfortran/66458] " pinskia at gcc dot gnu.org
2015-06-08 10:06 ` jan at epgmod dot phys.tue.nl
2015-06-08 15:16 ` kargl at gcc dot gnu.org
2015-07-05 12:13 ` fxcoudert at gcc dot gnu.org
2015-08-06 18:16 ` fxcoudert at gcc dot gnu.org
2015-08-07 16:24 ` fxcoudert at gcc dot gnu.org
2015-08-08  7:22 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).