sách gpt4 ai đã đi

ada - Chuyển đổi kiểu và biểu thức if

In lại 作者:行者123 更新时间:2023-12-05 03:17:35 26 4
mua khóa gpt4 Nike

hiện hữucái này页,John Barnes 写道:

If the conditional expression is the argument of a type conversion then effectively the conversion is considered pushed down to the dependent expressions. Thus

X := Float(if P then A else B);

is equivalent to

X := (if P then Float(A) else Float(B));

那么为什么我不能在 GNAT 10.3.0 下编译以下程序?

procedure Main is
P : Boolean := True;
X : Float;
begin
X := Float (if P then 0.5 else 32);
end Main;
Biên dịch
[Ada] main.adb
main.adb:5:35: expected a real type
main.adb:5:35: found type universal integer
gprbuild: *** compilation phase failed

1 Câu trả lời

因为你在编译器中发现了一个长期存在的错误! (GCC 12.1.0 中的行为相同)。

John Barnes 的理由是 AARM 4.5.7(10ff) .


感谢您提供真实代码和错误消息!

关于ada - 类型转换和 if 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74087195/

26 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com