Skip to content

Commit da19abe

Browse files
committed
Tolerate TS 18661 (_Float32 et al) types
Because we currently claim GCC 4.2.1 support, but also define the TS 18661 floating point types, we confuse Glibc 2.27+, which checks for GCC >= 7.0 and otherwise defines the types itself. In the long run we should either upgrade our support to GCC 7.0 standard, or else stop providing these types and simply ask users interested in these types to use Glibc 2.27 or provide their own headers; in the meantime this workaround permits us to avoid crashing whenever math.h is included.
1 parent ac6eb21 commit da19abe

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
typedef float _Float32;
2+
typedef double _Float32x;
3+
typedef double _Float64;
4+
typedef long double _Float64x;
5+
typedef long double _Float128;
6+
typedef long double _Float128x;
7+
8+
int main(int argc, char** argv) {
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,22 @@ void ansi_c_convert_typet::write(typet &type)
344344
gcc_float64_cnt+gcc_float64x_cnt+
345345
gcc_float128_cnt+gcc_float128x_cnt>=2)
346346
{
347-
error().source_location=source_location;
348-
error() << "conflicting type modifiers" << eom;
349-
throw 0;
347+
// Temporary workaround for our glibc versions that try to define TS 18661
348+
// types (for example, typedef float _Float32). This can be removed once
349+
// upgrade cbmc's GCC support to at least 7.0 (when glibc will expect us
350+
// to provide these types natively), or disable parsing them ourselves
351+
// when our preprocessor stage claims support <7.0.
352+
if(c_storage_spec.is_typedef)
353+
{
354+
warning().source_location = source_location;
355+
warning() << "ignoring typedef for TS 18661 (_FloatNNx) type. If you need these, try using goto-cc instead." << eom;
356+
}
357+
else
358+
{
359+
error().source_location=source_location;
360+
error() << "conflicting type modifiers" << eom;
361+
throw 0;
362+
}
350363
}
351364

352365
// _not_ the same as float, double, long double

0 commit comments

Comments
 (0)