bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c99+ pragma is ignored by gcc -std=gnu99


From: Paul Eggert
Subject: Re: c99+ pragma is ignored by gcc -std=gnu99
Date: Tue, 15 Nov 2005 10:51:35 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> In compiling coreutils with -std=gnu99, I see this new warning:
>
>   xstrtod.c:33: warning: ignoring #pragma STDC FENV_ACCESS
>
> Why was this code needed?

The C standard says that all code that runs when the rounding mode is
altered must be compiled with that pragma.

At the time that code was written, coreutils was altering the rounding
mode in order to support df.  However, coreutils no longer alters the
rounding mode (it solves the problem a different way).

However, strictly speaking coreutils should still alter the rounding
mode, for "sleep".  For example, on my Debian stable x86 host the
command "sleep 100000000.000000001" neglects the fraction due to
rounding errors.  This violates the basic promise of "sleep" that it
will sleep for at least as many seconds as asked.

The "right" way to fix this probably involves having a compile-time
switch by the application saying whether it messes with the rounding
modes and the pragma is needed in gnulib modules that use
floating-point, and I suppose we could also check whether GCC is
running in the mode where it generates that bogus warning.

However, for now the simplest thing to do is to remove the pragma so I
installed the following patch, in both gnulib and coreutils.

2005-11-15  Paul Eggert  <address@hidden>

        * xstrtod.c: Don't bother with #pragma STDC FENV_ACCESS ON, as
        coreutils no longer futzes with rounding modes.

--- xstrtod.c.~1.11.~   2005-05-14 00:58:07.000000000 -0700
+++ xstrtod.c   2005-11-15 10:11:17.000000000 -0800
@@ -1,6 +1,7 @@
 /* error-checking interface to strtod-like functions
 
-   Copyright (C) 1996, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1999, 2000, 2003, 2004, 2005 Free Software
+   Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -28,11 +29,6 @@
 #include <limits.h>
 #include <stdio.h>
 
-/* Tell the compiler that non-default rounding modes are used.  */
-#if 199901 <= __STDC_VERSION__
- #pragma STDC FENV_ACCESS ON
-#endif
-
 /* An interface to strtod that encapsulates all the error checking
    one should usually perform.  Like strtod, but upon successful
    conversion put the result in *RESULT and return true.  Return




reply via email to

[Prev in Thread] Current Thread [Next in Thread]