ada - 检测 GNAT 预定义库中的匿名分配
问题描述
所以我正在开发一个不应从默认池执行分配的 Ada 2012 库;所有这些都应该使用用户指定的存储池。
我正在使用一些预定义的包,其中一些显然不遵守规则:例如无限期容器。我想确定我没有使用我不应该使用的东西。
我认为一些 pragma Restrictions 可能会有所帮助,但以下都没有抱怨:
pragma Restrictions (No_Allocators);
pragma Restrictions (No_Anonymous_Allocators);
pragma Restrictions (No_Implicit_Heap_Allocations);
pragma Restrictions (No_Standard_Allocators_After_Elaboration);
pragma Restrictions (No_Standard_Storage_Pools);
with Ada.Containers.Indefinite_Vectors;
procedure Anon is
package Vectors is new Ada.Containers.Indefinite_Vectors (Positive, String);
V : Vectors.Vector;
begin
V.Append ("Mmm");
end Anon;
我不确定为什么没有检测到,或者是否应该检测到(即使是预编译的,编译器库也应该有包含此信息的 .ali 文件)。如果没有,有没有办法做到这一点?
a-coinve.ads
这是在没有任何存储池的情况下声明的指针类型:type Elements_Access is access all Elements_Type;
这在带有常规的主体中使用new
。
(编辑澄清我的意思是来自默认池的分配,而不是匿名访问类型)。
解决方案
如果我没记错的话,您可以覆盖所有访问类型的默认存储池(包括在标准库中声明的那些)。
我发现的第一个选项是 LRM 中的 13.11.3。它看起来不像我记得的那样,但pragma Default_Storage_Pool (null);
用作配置编译指示应该——据我所知——也涵盖运行时库。
推荐阅读
- android - Google Play 警告:您的应用包含基于文件的 XSS 问题?JavaScript 启用 = 真
- php - 安装我的自定义插件后创建自定义 wordpress 页面
- python - 字符串中的一个热门 - 获取唯一列表中的索引
- abstract-syntax-tree - ASIS中元素的子元素列表(Ada语义接口规范)
- ios - 我可以调用 semaphore.wait() 主线程吗?
- matrix-multiplication - PyTorch中不同形状张量的点积
- python - 如何为离线绘图设置通用色阶?
- adobe - PDF 框中的“JavaScript 窗口”对话框中的警告消息
- javascript - 如何处理 Angular 4 及以后的大数据
- java - 下载管理器程序因带宽较低而失败