This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
nexttoward/nextafter attribute question
- From: Steve Ellcey <sellcey at cavium dot com>
- To: gcc <gcc at gcc dot gnu dot org>
- Date: Mon, 11 Dec 2017 12:59:34 -0800
- Subject: nexttoward/nextafter attribute question
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Steve dot Ellcey at cavium dot com;
- Reply-to: sellcey at cavium dot com
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
I have a question about the attributes that GCC is putting on the
nexttoward/nextafter builtin functions. This issue started when
ToT glibc ran into a problem when building with ToT GCC after Martin
Sebor added a patch to GCC that tightened up the attribute checking
that GCC does.
The line below no longer compiles cleanly with -Wall -frounding-math -fno-math-errno:
extern double nexttoward (double __x, long double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));
When I look at the GCC sources it appears that the attribute on this function
(and on the other nextoward and nextafter functions) changesbased on the GCC
arguments:
-frounding-math -fno-math-errno: __attribute__ ((__pure__))
-fno-math-errno: __attribute__ ((__const__))
-frounding-math: __attribute__ ((__const__))
<neither option>: __attribute__ ((__const__))
I have several questions about this; one is why rounding-math affects
the attribute. The other is why the function would be pure with
-fno-math-errno but const otherwise. I would think that the -fno-math-errno
version would be const (stricter than pure) since it is not setting
errno. Finally, how can I check if -frounding-mode is set in the compiler
or not. If I want the glibc sources to match the GCC attributes I need
to know if -frounding-math is set but there does not seem to be a way
to do that. Using -fno-math-errno will set __NO_MATH_ERRNO__ but there
does not seem to be an equivelent macro for -frounding-math.
Steve Ellcey
sellcey@cavium.com