Bug 3516 - Simplify bits/mathdef.h files
Summary: Simplify bits/mathdef.h files
Status: RESOLVED WONTFIX
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.4
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-13 17:54 UTC by Joseph Myers
Modified: 2016-05-08 14:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
Patch to simplify bits/mathdef.h files. (1011 bytes, patch)
2006-11-13 17:55 UTC, Joseph Myers
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Myers 2006-11-13 17:54:24 UTC
bits/mathdef.h defines float_t to be the type the compiler uses for arithmetic
on float values.  If FLT_EVAL_METHOD is 0, then C99 (7.12#2) requires float_t to
be float; FLT_EVAL_METHOD is 0 with GCC on all processors except x86 and m68k
(so float_t being something else in glibc indicates a bug in either GCC or
glibc, except on those processors).

For some processors such as PowerPC, glibc has the following logic to determine
float_t:

# ifdef __GNUC__
#  if __STDC__ == 1

/* In GNU or ANSI mode, gcc leaves `float' expressions as-is.  */
typedef float float_t;          /* `float' expressions are evaluated as
                                   `float'.  */
typedef double double_t;        /* `double' expressions are evaluated as
                                   `double'.  */

#  else

/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
typedef double float_t;         /* `float' expressions are evaluated as
                                   `double'.  */
typedef double double_t;        /* `double' expressions are evaluated as
                                   `double'.  */

#  endif
# else

/* Wild guess at types for float_t and double_t. */
typedef double float_t;
typedef double double_t;

# endif

This has several problems:

* The __STDC__ == 1 conditional is interpreted by GCC's fixincludes as intended
to mean strict conformance mode, and so is rewritten to check __STRICT_ANSI__,
meaning that in default non-strict mode you actually get the incorrect double type.

* glibc doesn't support pre-standard C at all.  There's no point in having
__STDC__ checks *anywhere* in glibc to allow for pre-standard C.  GCC hasn't
supported -traditional for some time either.  Anyway, these are C99 definitions;
hardly likely to be of use in a compatibility mode for ancient code.

* The "Wild guess" default of double for float_t for other compilers is unlikely
to be right; these processors support float arithmetic, so other compilers are
more likely to use float arithmetic.

Thus it's simpler, more accurate and avoids the header being changed by
fixincludes just to use

typedef float float_t;
typedef double double_t;

unconditionally for these targets.  I'll attach a patch to do so.
Comment 1 Joseph Myers 2006-11-13 17:55:09 UTC
Created attachment 1416 [details]
Patch to simplify bits/mathdef.h files.
Comment 2 Ulrich Drepper 2006-11-13 19:32:30 UTC
There is *NO* reason whatsoever to make the change.  Changing just for the sake
of it won't happen.