Ada:了解变量大小和类型 Size vs value_size vs object_size

Ada: Understanding variable'Size vs type'Size vs value_size vs object_size

定义以下 Ada 类型:

type Type_Huge is array (1 .. Integer'Last) of Float;
type Type_B is (foo, bar, blop, bloub);
type Type_A ( disc : Type_B := foo) is
    record
        case disc is
            when foo =>
                My_int : Integer;
            when bar =>
                huge_data : Type_Huge := (others => 0.0);
            when others =>
                null;
        end case;
    end record;

1- 您确认以下内容吗?

my_var : Type_A;

(Type_A'Size = my_var'Size) returns False

2- my_var'Size 的实际价值是多少? 我会说尺寸至少是:

Type_B'Size + Integer'Size

3- Type_A'Size 的值是多少?

我会说大小是可能配置的最大值。

3- 编译器是否会向 my_var 添加(可能隐藏)任何其他内容?

我还阅读了一些关于 Value_SizeObject_Size 的文章 但我现在没有得到完整的图片。

感谢

引用 LRM 中的第 13.3 节:

(44) For every subtype S:

(45) S'Size [...]

(48) If S is indefinite, the meaning is implementation defined. [...]

换句话说:它是实现定义的。

the LRM requires 'Size be defined by the implementation for indefinite types; in addition, LRM M.2 (45) 中所引用,要求实施记录此特征:

(45) The meaning of Size for indefinite subtypes.

如果您的编译器是 GNAT,则参考手册中的说明如下:

Size for an indefinite subtype is the maximum possible size, (...).

在添加编译器开关时可以看到编译器的选择-gnatR3。输出还列出了 'Value_Size 的数字,因为它们取决于记录判别式的值。 ((...)部分讨论子程序参数的大小。)