File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -84,13 +84,21 @@ exprt convert_float_literal(const std::string &src)
84
84
else
85
85
UNREACHABLE;
86
86
87
- const constant_exprt result = a.to_expr ();
87
+ constant_exprt result = a.to_expr ();
88
+ // ieee_floatt::to_expr gives us the representation, but doesn't preserve the
89
+ // distinction between bitwise-identical types such as _Float32 vs. float,
90
+ // so ensure we preserve that here:
91
+ result.type () = type;
88
92
89
93
if (parsed_float.is_imaginary )
90
94
{
91
95
const complex_typet complex_type (type);
92
- return complex_exprt (
93
- ieee_floatt::zero (type).to_expr (), result, complex_type);
96
+
97
+ constant_exprt zero_real_component = ieee_floatt::zero (type).to_expr ();
98
+ // As above, ensure we preserve the exact type of the literal:
99
+ zero_real_component.type () = type;
100
+
101
+ return complex_exprt (zero_real_component, result, complex_type);
94
102
}
95
103
96
104
return result;
You can’t perform that action at this time.
0 commit comments