mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-13 05:41:26 +01:00
Make _Complex_I a proper float _Complex when using GCC 4.2.
It turns out our GCC has quite an interesting bug: typeof(1.0fi) != float _Complex typeof((float _Complex)1.0fi) != float _Complex typeof((float _Complex)1.0i) == float _Complex In other words: if casting to an equal size, GCC seems to take a shortcut. By casting down from a double to a float, GCC doesn't take this shortcut, yielding the proper type. To prevent foot-shooting, add a _Static_assert() to guarantee that _Complex_I is always a float _Complex. I'm not going to MFC this part of the diff. MFC after: 2 weeks
This commit is contained in:
parent
5a39f779b2
commit
f92d9d7d37
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=229590
@ -29,11 +29,15 @@
|
||||
#ifndef _COMPLEX_H
|
||||
#define _COMPLEX_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if __STDC_VERSION__ < 199901
|
||||
#define _Complex __complex__
|
||||
#endif
|
||||
#define _Complex_I 1.0fi
|
||||
#define _Complex_I ((float _Complex)1.0i)
|
||||
_Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
|
||||
"_Complex_I must be of type float _Complex");
|
||||
#endif
|
||||
|
||||
#define complex _Complex
|
||||
|
Loading…
Reference in New Issue
Block a user